From 134fe96db0771709f8c7ce457f498ff8310f5152 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Fri, 29 Nov 2024 14:29:46 +0100 Subject: [PATCH] add field retrieval tags to scipost extras --- .../scipost/templatetags/scipost_extras.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scipost_django/scipost/templatetags/scipost_extras.py b/scipost_django/scipost/templatetags/scipost_extras.py index 2d712a3ca..26843c8be 100644 --- a/scipost_django/scipost/templatetags/scipost_extras.py +++ b/scipost_django/scipost/templatetags/scipost_extras.py @@ -68,7 +68,17 @@ def object_name(obj): return None else: # Add spaces before capital letters in the object name to make it more readable - return re.sub(r"[^\s]([A-Z])", r" \1", obj._meta.object_name) + return re.sub(r"([^\s])([A-Z])", r"\1 \2", obj._meta.object_name) + + +@register.filter(name="get_fields") +def get_fields(obj): + return obj._meta.get_fields() + + +@register.filter(name="get_field_value") +def get_field_value(obj, field_name): + return getattr(obj, field_name) @register.filter -- GitLab