Skip to content

Commit

Permalink
fix(core): add a model_meta templatetag filter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
b1rger committed Apr 11, 2024
1 parent ae78620 commit 9d60aa0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apis_core/core/templatetags/apiscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 9d60aa0

Please sign in to comment.