From 74e628ce9c4f3359e34b17eae922b76e47bc1a37 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 20 Jul 2020 14:43:38 +0200 Subject: [PATCH] ui: allow overriding of verbose_name --- passbook/lib/templatetags/passbook_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/passbook/lib/templatetags/passbook_utils.py b/passbook/lib/templatetags/passbook_utils.py index aa8cc062f..6acca985b 100644 --- a/passbook/lib/templatetags/passbook_utils.py +++ b/passbook/lib/templatetags/passbook_utils.py @@ -36,7 +36,7 @@ def back(context: Context) -> str: def fieldtype(field): """Return classname""" if isinstance(field.__class__, Model) or issubclass(field.__class__, Model): - return field._meta.verbose_name + return verbose_name(field) return field.__class__.__name__ @@ -84,6 +84,9 @@ def verbose_name(obj) -> str: """Return Object's Verbose Name""" if not obj: return "" + if hasattr(obj, "verbose_name"): + print(obj.verbose_name) + return obj.verbose_name return obj._meta.verbose_name @@ -92,7 +95,7 @@ def form_verbose_name(obj) -> str: """Return ModelForm's Object's Verbose Name""" if not obj: return "" - return obj._meta.model._meta.verbose_name + return verbose_name(obj._meta.model) @register.filter