diff --git a/netbox/templates/dcim/cable_connect.html b/netbox/templates/dcim/cable_connect.html index aa4c4bf8c..3d9d06a1f 100644 --- a/netbox/templates/dcim/cable_connect.html +++ b/netbox/templates/dcim/cable_connect.html @@ -53,7 +53,7 @@
-

{{ termination_a|model_name|capfirst }}

+

{{ termination_a|meta:"verbose_name"|capfirst }}

diff --git a/netbox/templates/dcim/inc/cable_termination.html b/netbox/templates/dcim/inc/cable_termination.html index 48af97a0b..0711ff121 100644 --- a/netbox/templates/dcim/inc/cable_termination.html +++ b/netbox/templates/dcim/inc/cable_termination.html @@ -11,7 +11,7 @@ Type - {{ termination|model_name|capfirst }} + {{ termination|meta:"verbose_name"|capfirst }} diff --git a/netbox/templates/dcim/inc/cable_trace_end.html b/netbox/templates/dcim/inc/cable_trace_end.html index 4eab4d1d7..6073c06ee 100644 --- a/netbox/templates/dcim/inc/cable_trace_end.html +++ b/netbox/templates/dcim/inc/cable_trace_end.html @@ -17,7 +17,7 @@
{% if end.device %} {# Device component #} - {% with model=end|model_name %} + {% with model=end|meta:"verbose_name" %} {{ model|bettertitle }} {{ end }}
{% if model == 'interface' %} {{ end.get_type_display }} diff --git a/netbox/templates/ipam/ipaddress_edit.html b/netbox/templates/ipam/ipaddress_edit.html index e3f694fe3..d8902595a 100644 --- a/netbox/templates/ipam/ipaddress_edit.html +++ b/netbox/templates/ipam/ipaddress_edit.html @@ -35,7 +35,7 @@
- +

{{ obj.interface.parent }} diff --git a/netbox/templates/utilities/obj_list.html b/netbox/templates/utilities/obj_list.html index e917819c6..8f9a0563c 100644 --- a/netbox/templates/utilities/obj_list.html +++ b/netbox/templates/utilities/obj_list.html @@ -15,7 +15,7 @@ {% export_button content_type %} {% endif %}

-

{% block title %}{{ content_type.model_class|model_name_plural|bettertitle }}{% endblock %}

+

{% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}

{% with bulk_edit_url=content_type.model_class|url_name:"bulk_edit" bulk_delete_url=content_type.model_class|url_name:"bulk_delete" %} diff --git a/netbox/utilities/templatetags/helpers.py b/netbox/utilities/templatetags/helpers.py index db4d59114..618641a07 100644 --- a/netbox/utilities/templatetags/helpers.py +++ b/netbox/utilities/templatetags/helpers.py @@ -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()