From 9d60aa09b51aadd5c95cbc49355d95a85d3450c8 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Thu, 11 Apr 2024 12:25:37 +0200 Subject: [PATCH] fix(core): add a model_meta templatetag filter This filter allows to access a models Meta options (https://docs.djangoproject.com/en/5.0/ref/models/options/) in a template via a ContentType object. --- apis_core/core/templatetags/apiscore.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apis_core/core/templatetags/apiscore.py b/apis_core/core/templatetags/apiscore.py index 6e0ae1f2f..6343be235 100644 --- a/apis_core/core/templatetags/apiscore.py +++ b/apis_core/core/templatetags/apiscore.py @@ -18,3 +18,8 @@ def page_range(paginator, number): @register.filter def opts(obj): return obj._meta + + +@register.filter +def model_meta(content_type, field): + return getattr(content_type.model_class()._meta, field)