From 51be747103cfe5c2ca9cc7179d33129bdbe0411f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 3 Jul 2022 23:13:23 +0100 Subject: [PATCH] Remove current page from part of navbar caching We don't show the currently active page in the nav, so this isn't necessary. This also allows the cache to be shared between pages. --- templates/base.html | 4 ++-- website/common/templatetags/navbar_tags.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/templates/base.html b/templates/base.html index e19a83d..c954997 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,8 +23,8 @@ {% wagtailuserbar %} - {% cache 3600 "navbar" page %} - {% navbar page %} + {% cache 3600 "navbar" %} + {% navbar %} {% endcache %} {% block main %} diff --git a/website/common/templatetags/navbar_tags.py b/website/common/templatetags/navbar_tags.py index 15a4c5a..1ccae63 100644 --- a/website/common/templatetags/navbar_tags.py +++ b/website/common/templatetags/navbar_tags.py @@ -1,5 +1,4 @@ from django.template import Library -from wagtail.models import Page from website.home.models import HomePage @@ -7,10 +6,9 @@ register = Library() @register.inclusion_tag("common/navbar.html") -def navbar(current_page: Page) -> dict: +def navbar() -> dict: homepage = HomePage.objects.live().get() return { - "current_page": current_page, "homepage": homepage, "nav_pages": homepage.get_children() .live()