Replace model_name and model_name_verbose filters with meta

This commit is contained in:
Jeremy Stretch
2020-03-09 10:50:46 -04:00
parent 16d3cebf3e
commit 15ab30d0c6
6 changed files with 9 additions and 16 deletions

View File

@@ -62,19 +62,12 @@ def render_yaml(value):
@register.filter()
def model_name(obj):
def meta(obj, attr):
"""
Return the name of the model of the given object
Return the specified Meta attribute of a model. This is needed because Django does not permit templates
to access attributes which begin with an underscore (e.g. _meta).
"""
return obj._meta.verbose_name
@register.filter()
def model_name_plural(obj):
"""
Return the plural name of the model of the given object
"""
return obj._meta.verbose_name_plural
return getattr(obj._meta, attr, '')
@register.filter()