mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-21 04:42:22 -06:00
Replace model_name and model_name_verbose filters with meta
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user