Cache all object list templates

This commit is contained in:
Mark Veidemanis 2023-02-11 14:52:00 +00:00
parent 0acddb2048
commit a0c94b2097
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
16 changed files with 1000 additions and 967 deletions

View File

@ -68,6 +68,9 @@ CACHES = {
}, },
} }
} }
# CACHE_MIDDLEWARE_ALIAS = 'default'
# CACHE_MIDDLEWARE_SECONDS = '600'
# CACHE_MIDDLEWARE_KEY_PREFIX = ''
CRISPY_TEMPLATE_PACK = "bulma" CRISPY_TEMPLATE_PACK = "bulma"
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",) CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
@ -77,16 +80,15 @@ MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware", "debug_toolbar.middleware.DebugToolbarMiddleware",
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
# 'django.middleware.cache.UpdateCacheMiddleware',
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
# 'django.middleware.cache.FetchFromCacheMiddleware',
"django.middleware.csrf.CsrfViewMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django_otp.middleware.OTPMiddleware", "django_otp.middleware.OTPMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_htmx.middleware.HtmxMiddleware", "django_htmx.middleware.HtmxMiddleware",
# 'django.middleware.cache.UpdateCacheMiddleware',
# 'django.middleware.common.CommonMiddleware',
# 'django.middleware.cache.FetchFromCacheMiddleware',
] ]
ROOT_URLCONF = "app.urls" ROOT_URLCONF = "app.urls"

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_accounts request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -110,3 +111,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_assetgroups request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -70,3 +71,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_assetrestrictions request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -69,3 +70,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_callbacks request.user.id object_list %}
<table class="table is-fullwidth is-hoverable" id="callbacks-table"> <table class="table is-fullwidth is-hoverable" id="callbacks-table">
<thead> <thead>
<th>id</th> <th>id</th>
@ -48,3 +49,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_hooks request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -90,3 +91,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,8 @@
{% extends 'partials/generic-detail.html' %} {% extends 'partials/generic-detail.html' %}
{% load cache %}
{% block tbody %} {% block tbody %}
{% cache 600 object_position_detail request.user.id object %}
{% for key, item in object.items %} {% for key, item in object.items %}
<tr> <tr>
{% if key == 'trade_ids' %} {% if key == 'trade_ids' %}
@ -30,4 +32,5 @@
{% endif %} {% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
{% endcache %}
{% endblock %} {% endblock %}

View File

@ -1,4 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_positions request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -100,3 +102,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,8 +1,9 @@
{% load static %} {% load static %}
{% load cache %}
{% cache 600 objects_plans request.user.id plans %}
{% for plan in plans %} {% for plan in plans %}
<div class="box"> <div class="box">
<article class="media"> <article class="media">
<div class="media-left"> <div class="media-left">
@ -45,4 +46,4 @@
</div> </div>
{% endfor %} {% endfor %}
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_profit request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -30,3 +31,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_risk request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -63,3 +64,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_signals request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -97,3 +98,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_strategies request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -96,3 +97,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_trades request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -90,3 +91,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_tradingtimes request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -59,3 +60,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,5 +1,6 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_trenddirections request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
@ -53,3 +54,4 @@
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}