From adcd97dd985797a724a7e892bc166f728750e3ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Thu, 6 Aug 2020 01:14:40 +0800 Subject: [PATCH] Revised the title_case template filter to work with gettext_lazy() in the Mia core application. --- mia_core/templatetags/mia_core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mia_core/templatetags/mia_core.py b/mia_core/templatetags/mia_core.py index 03a3479..41cb13f 100644 --- a/mia_core/templatetags/mia_core.py +++ b/mia_core/templatetags/mia_core.py @@ -25,6 +25,7 @@ from django import template from django.template import defaultfilters from django.urls import reverse from django.utils import timezone +from django.utils.safestring import SafeString from django.utils.translation import gettext from mia_core.status import retrieve_status @@ -230,4 +231,7 @@ def title_case(value): Returns: str: The title in a proper American-English case. """ + value = str(value) + if isinstance(value, SafeString): + value = value + "" return titlecase.titlecase(value)