From b893bcdee32a640f148e1682485da849f0058f31 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Thu, 28 Jul 2022 04:29:58 +0900 Subject: [PATCH] Make site_branding tag work with Django 4.0 A test for site_branding tag starts to fail with Django 4.0. It seems to happen as settings.SITE_BRANDING is _("Horizon") and a translation marker _() is no longer evaluated during rendering. As a solution, this commit changes the implementation of site_branding tag to use "simple_tag" method as django.template.Library.simple_tag() [1] seems to handle an i18n-ed string properly. [1] https://docs.djangoproject.com/en/4.0/howto/custom-template-tags/#simple-tags Closes-Bug: #1980214 Change-Id: I6fdfffbeef2b405da21289d37722e3f068e27fea --- horizon/templatetags/branding.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/horizon/templatetags/branding.py b/horizon/templatetags/branding.py index 3c208fd905..23771b9afb 100644 --- a/horizon/templatetags/branding.py +++ b/horizon/templatetags/branding.py @@ -27,14 +27,9 @@ from django import template register = template.Library() -class SiteBrandingNode(template.Node): - def render(self, context): - return settings.SITE_BRANDING - - -@register.tag -def site_branding(parser, token): - return SiteBrandingNode() +@register.simple_tag +def site_branding(): + return settings.SITE_BRANDING @register.tag