Просмотр исходного кода

Merge pull request #8943 from netbox-community/8912-linkify-filter

Closes #8912: Add linkify template filter
Jeremy Stretch 3 лет назад
Родитель
Сommit
61eb22f4f7
72 измененных файлов с 285 добавлено и 747 удалено
  1. 2 0
      docs/plugins/development/templates.md
  2. 5 11
      netbox/templates/circuits/circuit.html
  3. 6 8
      netbox/templates/circuits/inc/circuit_termination.html
  4. 1 3
      netbox/templates/circuits/providernetwork.html
  5. 3 7
      netbox/templates/dcim/cable.html
  6. 1 1
      netbox/templates/dcim/cable_trace.html
  7. 5 17
      netbox/templates/dcim/consoleport.html
  8. 5 15
      netbox/templates/dcim/consoleserverport.html
  9. 19 31
      netbox/templates/dcim/device.html
  10. 2 6
      netbox/templates/dcim/devicebay.html
  11. 1 1
      netbox/templates/dcim/devicetype.html
  12. 4 14
      netbox/templates/dcim/frontport.html
  13. 10 26
      netbox/templates/dcim/inc/cable_termination.html
  14. 2 2
      netbox/templates/dcim/inc/cabletermination.html
  15. 2 2
      netbox/templates/dcim/inc/endpoint_connection.html
  16. 2 6
      netbox/templates/dcim/inc/interface_vlans_table.html
  17. 1 1
      netbox/templates/dcim/inc/nonracked_devices.html
  18. 3 13
      netbox/templates/dcim/inc/panels/inventory_items.html
  19. 20 74
      netbox/templates/dcim/interface.html
  20. 5 31
      netbox/templates/dcim/inventoryitem.html
  21. 9 19
      netbox/templates/dcim/location.html
  22. 3 9
      netbox/templates/dcim/module.html
  23. 2 6
      netbox/templates/dcim/modulebay.html
  24. 1 1
      netbox/templates/dcim/moduletype.html
  25. 1 7
      netbox/templates/dcim/platform.html
  26. 6 18
      netbox/templates/dcim/powerfeed.html
  27. 5 17
      netbox/templates/dcim/poweroutlet.html
  28. 3 11
      netbox/templates/dcim/powerpanel.html
  29. 5 17
      netbox/templates/dcim/powerport.html
  30. 14 40
      netbox/templates/dcim/rack.html
  31. 7 19
      netbox/templates/dcim/rackreservation.html
  32. 3 11
      netbox/templates/dcim/rearport.html
  33. 1 7
      netbox/templates/dcim/region.html
  34. 9 13
      netbox/templates/dcim/site.html
  35. 1 7
      netbox/templates/dcim/sitegroup.html
  36. 2 2
      netbox/templates/dcim/trace/circuit.html
  37. 4 4
      netbox/templates/dcim/trace/device.html
  38. 1 1
      netbox/templates/dcim/trace/object.html
  39. 2 2
      netbox/templates/dcim/trace/powerpanel.html
  40. 1 1
      netbox/templates/dcim/trace/termination.html
  41. 2 8
      netbox/templates/dcim/virtualchassis.html
  42. 1 3
      netbox/templates/dcim/virtualchassis_edit.html
  43. 1 1
      netbox/templates/extras/configcontext.html
  44. 1 1
      netbox/templates/extras/imageattachment_edit.html
  45. 3 9
      netbox/templates/extras/journalentry.html
  46. 1 1
      netbox/templates/extras/object_configcontext.html
  47. 1 1
      netbox/templates/extras/objectchange.html
  48. 1 3
      netbox/templates/inc/panels/contacts.html
  49. 2 2
      netbox/templates/inc/panels/custom_fields.html
  50. 3 7
      netbox/templates/ipam/aggregate.html
  51. 3 7
      netbox/templates/ipam/asn.html
  52. 4 11
      netbox/templates/ipam/inc/panels/fhrp_groups.html
  53. 1 1
      netbox/templates/ipam/inc/service.html
  54. 8 18
      netbox/templates/ipam/ipaddress.html
  55. 5 15
      netbox/templates/ipam/iprange.html
  56. 9 19
      netbox/templates/ipam/prefix.html
  57. 1 7
      netbox/templates/ipam/routetarget.html
  58. 2 4
      netbox/templates/ipam/service.html
  59. 6 16
      netbox/templates/ipam/vlan.html
  60. 2 7
      netbox/templates/ipam/vlangroup.html
  61. 3 4
      netbox/templates/ipam/vrf.html
  62. 1 7
      netbox/templates/tenancy/contact.html
  63. 1 7
      netbox/templates/tenancy/contactgroup.html
  64. 1 7
      netbox/templates/tenancy/tenant.html
  65. 1 7
      netbox/templates/tenancy/tenantgroup.html
  66. 6 19
      netbox/templates/virtualization/cluster.html
  67. 7 23
      netbox/templates/virtualization/virtualmachine.html
  68. 4 24
      netbox/templates/virtualization/vminterface.html
  69. 2 6
      netbox/templates/wireless/inc/wirelesslink_interface.html
  70. 2 14
      netbox/templates/wireless/wirelesslan.html
  71. 1 7
      netbox/templates/wireless/wirelesslangroup.html
  72. 20 0
      netbox/utilities/templatetags/builtins/filters.py

+ 2 - 0
docs/plugins/development/templates.md

@@ -230,6 +230,8 @@ The following custom template filters are available in NetBox.
 
 
 ::: utilities.templatetags.builtins.filters.content_type_id
 ::: utilities.templatetags.builtins.filters.content_type_id
 
 
+::: utilities.templatetags.builtins.filters.linkify
+
 ::: utilities.templatetags.builtins.filters.meta
 ::: utilities.templatetags.builtins.filters.meta
 
 
 ::: utilities.templatetags.builtins.filters.placeholder
 ::: utilities.templatetags.builtins.filters.placeholder

+ 5 - 11
netbox/templates/circuits/circuit.html

@@ -18,9 +18,7 @@
                 <table class="table table-hover attr-table">
                 <table class="table table-hover attr-table">
                     <tr>
                     <tr>
                         <th scope="row">Provider</th>
                         <th scope="row">Provider</th>
-                        <td>
-                            <a href="{{ object.provider.get_absolute_url }}">{{ object.provider }}</a>
-                        </td>
+                        <td>{{ object.provider|linkify }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Circuit ID</th>
                         <th scope="row">Circuit ID</th>
@@ -28,7 +26,7 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Type</th>
                         <th scope="row">Type</th>
-                        <td><a href="{{ object.type.get_absolute_url }}">{{ object.type }}</a></td>
+                        <td>{{ object.type|linkify }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Status</th>
                         <th scope="row">Status</th>
@@ -37,14 +35,10 @@
                     <tr>
                     <tr>
                         <th scope="row">Tenant</th>
                         <th scope="row">Tenant</th>
                         <td>
                         <td>
-                            {% if object.tenant %}
-                                {% if object.tenant.group %}
-                                    <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                                {% endif %}
-                                <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
+                            {% if object.tenant.group %}
+                                {{ object.tenant.group|linkify }} /
                             {% endif %}
                             {% endif %}
+                            {{ object.tenant|linkify|placeholder }}
                         </td>
                         </td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>

+ 6 - 8
netbox/templates/circuits/inc/circuit_termination.html

@@ -32,9 +32,9 @@
               <td>Site</td>
               <td>Site</td>
               <td>
               <td>
                 {% if termination.site.region %}
                 {% if termination.site.region %}
-                  <a href="{{ termination.site.region.get_absolute_url }}">{{ termination.site.region }}</a> /
+                  {{ termination.site.region|linkify }} /
                 {% endif %}
                 {% endif %}
-                <a href="{{ termination.site.get_absolute_url }}">{{ termination.site }}</a>
+                {{ termination.site|linkify }}
               </td>
               </td>
             </tr>
             </tr>
             <tr>
             <tr>
@@ -48,11 +48,11 @@
                   {% with peer=termination.get_link_peer %}
                   {% with peer=termination.get_link_peer %}
                     to
                     to
                     {% if peer.device %}
                     {% if peer.device %}
-                      <a href="{{ peer.device.get_absolute_url }}">{{ peer.device }}</a><br/>
+                      {{ peer.device|linkify }}<br/>
                     {% elif peer.circuit %}
                     {% elif peer.circuit %}
-                      <a href="{{ peer.circuit.get_absolute_url }}">{{ peer.circuit }}</a><br/>
+                      {{ peer.circuit|linkify }}<br/>
                     {% endif %}
                     {% endif %}
-                    <a href="{{ peer.get_absolute_url }}">{{ peer }}</a>
+                    {{ peer|linkify }}
                   {% endwith %}
                   {% endwith %}
                   <div class="mt-1">
                   <div class="mt-1">
                     <a href="{% url 'circuits:circuittermination_trace' pk=termination.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                     <a href="{% url 'circuits:circuittermination_trace' pk=termination.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
@@ -82,9 +82,7 @@
           {% else %}
           {% else %}
             <tr>
             <tr>
               <td>Provider Network</td>
               <td>Provider Network</td>
-              <td>
-                <a href="{{ termination.provider_network.get_absolute_url }}">{{ termination.provider_network }}</a>
-              </td>
+              <td>{{ termination.provider_network|linkify }}</td>
             </tr>
             </tr>
           {% endif %}
           {% endif %}
             <tr>
             <tr>

+ 1 - 3
netbox/templates/circuits/providernetwork.html

@@ -20,9 +20,7 @@
                 <table class="table table-hover attr-table">
                 <table class="table table-hover attr-table">
                     <tr>
                     <tr>
                         <th scope="row">Provider</th>
                         <th scope="row">Provider</th>
-                        <td>
-                            <a href="{{ object.provider.get_absolute_url }}">{{ object.provider }}</a>
-                        </td>
+                        <td>{{ object.provider|linkify }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Name</th>
                         <th scope="row">Name</th>

+ 3 - 7
netbox/templates/dcim/cable.html

@@ -24,14 +24,10 @@
                         <tr>
                         <tr>
                             <th scope="row">Tenant</th>
                             <th scope="row">Tenant</th>
                             <td>
                             <td>
-                                {% if object.tenant %}
-                                    {% if object.tenant.group %}
-                                        <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                                    {% endif %}
-                                    <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
+                                {% if object.tenant.group %}
+                                    {{ object.tenant.group|linkify }} /
                                 {% endif %}
                                 {% endif %}
+                                {{ object.tenant|linkify|placeholder }}
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>

+ 1 - 1
netbox/templates/dcim/cable_trace.html

@@ -25,7 +25,7 @@
                                 {% if next_node.cable %}
                                 {% if next_node.cable %}
                                     <li>
                                     <li>
                                         <a href="{% url 'dcim:frontport_trace' pk=next_node.pk %}">{{ next_node }}</a>
                                         <a href="{% url 'dcim:frontport_trace' pk=next_node.pk %}">{{ next_node }}</a>
-                                        (Cable <a href="{{ next_node.cable.get_absolute_url }}">{{ next_node.cable }}</a>)
+                                        (Cable {{ next_node.cable|linkify }})
                                     </li>
                                     </li>
                                 {% else %}
                                 {% else %}
                                     <li class="text-muted">{{ next_node }}</li>
                                     <li class="text-muted">{{ next_node }}</li>

+ 5 - 17
netbox/templates/dcim/consoleport.html

@@ -20,19 +20,11 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Module</th>
                             <th scope="row">Module</th>
-                            <td>
-                              {% if object.module %}
-                                <a href="{{ object.module.get_absolute_url }}">{{ object.module }}</a>
-                              {% else %}
-                                {{ None|placeholder }}
-                              {% endif %}
-                            </td>
+                            <td>{{ object.module|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -74,7 +66,7 @@
                             <tr>
                             <tr>
                                 <th scope="row">Cable</th>
                                 <th scope="row">Cable</th>
                                 <td>
                                 <td>
-                                    <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                                    {{ object.cable|linkify }}
                                     <a href="{% url 'dcim:consoleport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <a href="{% url 'dcim:consoleport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                         <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                         <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     </a>
                                     </a>
@@ -83,15 +75,11 @@
                             {% if object.connected_endpoint %}
                             {% if object.connected_endpoint %}
                                 <tr>
                                 <tr>
                                     <th scope="row">Device</th>
                                     <th scope="row">Device</th>
-                                    <td>
-                                        <a href="{{ object.connected_endpoint.device.get_absolute_url }}">{{ object.connected_endpoint.device }}</a>
-                                    </td>
+                                    <td>{{ object.connected_endpoint.device|linkify }}</td>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
                                     <th scope="row">Name</th>
                                     <th scope="row">Name</th>
-                                    <td>
-                                        <a href="{{ object.connected_endpoint.get_absolute_url }}">{{ object.connected_endpoint.name }}</a>
-                                    </td>
+                                    <td>{{ object.connected_endpoint|linkify:"name" }}</td>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
                                     <th scope="row">Type</th>
                                     <th scope="row">Type</th>

+ 5 - 15
netbox/templates/dcim/consoleserverport.html

@@ -20,19 +20,11 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Module</th>
                             <th scope="row">Module</th>
-                            <td>
-                              {% if object.module %}
-                                <a href="{{ object.module.get_absolute_url }}">{{ object.module }}</a>
-                              {% else %}
-                                {{ None|placeholder }}
-                              {% endif %}
-                            </td>
+                            <td>{{ object.module|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -74,7 +66,7 @@
                         <tr>
                         <tr>
                             <th scope="row">Cable</th>
                             <th scope="row">Cable</th>
                             <td>
                             <td>
-                                <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                                {{ object.cable|linkify }}
                                 <a href="{% url 'dcim:consoleserverport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                 <a href="{% url 'dcim:consoleserverport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                 </a>
                                 </a>
@@ -84,14 +76,12 @@
                             <tr>
                             <tr>
                                 <th scope="row">Device</th>
                                 <th scope="row">Device</th>
                                 <td>
                                 <td>
-                                    <a href="{{ object.connected_endpoint.device.get_absolute_url }}">{{ object.connected_endpoint.device }}</a>
+                                    {{ object.connected_endpoint.device|linkify }}
                                 </td>
                                 </td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <th scope="row">Name</th>
                                 <th scope="row">Name</th>
-                                <td>
-                                    <a href="{{ object.connected_endpoint.get_absolute_url }}">{{ object.connected_endpoint.name }}</a>
-                                </td>
+                                <td>{{ object.connected_endpoint|linkify:"name" }}</td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <th scope="row">Type</th>
                                 <th scope="row">Type</th>

+ 19 - 31
netbox/templates/dcim/device.html

@@ -19,28 +19,26 @@
                             <td>
                             <td>
                                 {% if object.site.region %}
                                 {% if object.site.region %}
                                     {% for region in object.site.region.get_ancestors %}
                                     {% for region in object.site.region.get_ancestors %}
-                                    <a href="{{ region.get_absolute_url }}">{{ region }}</a> /
+                                        {{ region|linkify }} /
                                     {% endfor %}
                                     {% endfor %}
-                                    <a href="{{ object.site.region.get_absolute_url }}">{{ object.site.region }}</a>
+                                    {{ object.site.region|linkify }}
                                 {% else %}
                                 {% else %}
-                                <span class="text-muted">None</span>
+                                    <span class="text-muted">None</span>
                                 {% endif %}
                                 {% endif %}
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Site</th>
                             <th scope="row">Site</th>
-                            <td>
-                                <a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a>
-                            </td>
+                            <td>{{ object.site|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Location</th>
                             <th scope="row">Location</th>
                             <td>
                             <td>
                             {% if object.location %}
                             {% if object.location %}
                                 {% for location in object.location.get_ancestors %}
                                 {% for location in object.location.get_ancestors %}
-                                    <a href="{{ location.get_absolute_url }}">{{ location }}</a> /
+                                    {{ location|linkify }} /
                                 {% endfor %}
                                 {% endfor %}
-                                <a href="{{ object.location.get_absolute_url }}">{{ object.location }}</a>
+                                {{ object.location|linkify }}
                             {% else %}
                             {% else %}
                                 <span class="text-muted">None</span>
                                 <span class="text-muted">None</span>
                             {% endif %}
                             {% endif %}
@@ -61,7 +59,7 @@
                             <td>
                             <td>
                                 {% if object.parent_bay %}
                                 {% if object.parent_bay %}
                                     {% with object.parent_bay.device as parent %}
                                     {% with object.parent_bay.device as parent %}
-                                        <a href="{{ parent.get_absolute_url }}">{{ parent }}</a> / {{ object.parent_bay }}
+                                        {{ parent|linkify }} / {{ object.parent_bay }}
                                         {% if parent.position %}
                                         {% if parent.position %}
                                             (U{{ parent.position }} / {{ parent.get_face_display }})
                                             (U{{ parent.position }} / {{ parent.get_face_display }})
                                         {% endif %}
                                         {% endif %}
@@ -78,20 +76,16 @@
                         <tr>
                         <tr>
                             <th scope="row">Tenant</th>
                             <th scope="row">Tenant</th>
                             <td>
                             <td>
-                                {% if object.tenant %}
-                                    {% if object.tenant.group %}
-                                        <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                                    {% endif %}
-                                    <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
+                                {% if object.tenant.group %}
+                                    {{ object.tenant.group|linkify }} /
                                 {% endif %}
                                 {% endif %}
+                                {{ object.tenant|linkify|placeholder }}
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Device Type</th>
                             <th scope="row">Device Type</th>
                             <td>
                             <td>
-                                <span><a href="{{ object.device_type.get_absolute_url }}">{{ object.device_type }}</a> ({{ object.device_type.u_height }}U)</span>
+                                {{ object.device_type|linkify }} ({{ object.device_type.u_height }}U)
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
@@ -127,7 +121,7 @@
                             {% for vc_member in vc_members %}
                             {% for vc_member in vc_members %}
                                 <tr{% if vc_member == object %} class="info"{% endif %}>
                                 <tr{% if vc_member == object %} class="info"{% endif %}>
                                     <td>
                                     <td>
-                                        <a href="{{ vc_member.get_absolute_url }}">{{ vc_member }}</a>
+                                        {{ vc_member|linkify }}
                                     </td>
                                     </td>
                                     <td>
                                     <td>
                                       {% badge vc_member.vc_position show_empty=True %}
                                       {% badge vc_member.vc_position show_empty=True %}
@@ -173,13 +167,7 @@
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Platform</th>
                             <th scope="row">Platform</th>
-                            <td>
-                                {% if object.platform %}
-                                <a href="{{ object.platform.get_absolute_url }}">{{ object.platform }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.platform|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Primary IPv4</th>
                             <th scope="row">Primary IPv4</th>
@@ -187,9 +175,9 @@
                               {% if object.primary_ip4 %}
                               {% if object.primary_ip4 %}
                                 <a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
                                 <a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
                                 {% if object.primary_ip4.nat_inside %}
                                 {% if object.primary_ip4.nat_inside %}
-                                  (NAT for <a href="{{ object.primary_ip4.nat_inside.get_absolute_url }}">{{ object.primary_ip4.nat_inside.address.ip }}</a>)
+                                  (NAT for {{ object.primary_ip4.nat_inside.address.ip|linkify }})
                                 {% elif object.primary_ip4.nat_outside %}
                                 {% elif object.primary_ip4.nat_outside %}
-                                  (NAT: <a href="{{ object.primary_ip4.nat_outside.get_absolute_url }}">{{ object.primary_ip4.nat_outside.address.ip }}</a>)
+                                  (NAT: {{ object.primary_ip4.nat_outside.address.ip|linkify }})
                                 {% endif %}
                                 {% endif %}
                               {% else %}
                               {% else %}
                                 <span class="text-muted">&mdash;</span>
                                 <span class="text-muted">&mdash;</span>
@@ -202,9 +190,9 @@
                               {% if object.primary_ip6 %}
                               {% if object.primary_ip6 %}
                                 <a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
                                 <a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
                                 {% if object.primary_ip6.nat_inside %}
                                 {% if object.primary_ip6.nat_inside %}
-                                  (NAT for <a href="{{ object.primary_ip6.nat_inside.get_absolute_url }}">{{ object.primary_ip6.nat_inside.address.ip }}</a>)
+                                  (NAT for {{ object.primary_ip6.nat_inside.address.ip|linkify }})
                                 {% elif object.primary_ip6.nat_outside %}
                                 {% elif object.primary_ip6.nat_outside %}
-                                  (NAT: <a href="{{ object.primary_ip6.nat_outside.get_absolute_url }}">{{ object.primary_ip6.nat_outside.address.ip }}</a>)
+                                  (NAT: {{ object.primary_ip6.nat_outside.address.ip|linkify }})
                                 {% endif %}
                                 {% endif %}
                               {% else %}
                               {% else %}
                                 <span class="text-muted">&mdash;</span>
                                 <span class="text-muted">&mdash;</span>
@@ -216,9 +204,9 @@
                                 <th>Cluster</th>
                                 <th>Cluster</th>
                                 <td>
                                 <td>
                                     {% if object.cluster.group %}
                                     {% if object.cluster.group %}
-                                        <a href="{{ object.cluster.group.get_absolute_url }}">{{ object.cluster.group }}</a> /
+                                        {{ object.cluster.group|linkify }} /
                                     {% endif %}
                                     {% endif %}
-                                    <a href="{{ object.cluster.get_absolute_url }}">{{ object.cluster }}</a>
+                                    {{ object.cluster|linkify }}
                                 </td>
                                 </td>
                             </tr>
                             </tr>
                         {% endif %}
                         {% endif %}

+ 2 - 6
netbox/templates/dcim/devicebay.html

@@ -20,9 +20,7 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -54,9 +52,7 @@
                         <table class="table table-hover attr-table">
                         <table class="table table-hover attr-table">
                             <tr>
                             <tr>
                                 <th scope="row">Device</th>
                                 <th scope="row">Device</th>
-                                <td>
-                                    <a href="{{ device.get_absolute_url }}">{{ device }}</a>
-                                </td>
+                                <td>{{ device|linkify }}</td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <th scope="row">Device Type</th>
                                 <th scope="row">Device Type</th>

+ 1 - 1
netbox/templates/dcim/devicetype.html

@@ -14,7 +14,7 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <td>Manufacturer</td>
                             <td>Manufacturer</td>
-                            <td><a href="{{ object.manufacturer.get_absolute_url }}">{{ object.manufacturer }}</a></td>
+                            <td>{{ object.manufacturer|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <td>Model Name</td>
                             <td>Model Name</td>

+ 4 - 14
netbox/templates/dcim/frontport.html

@@ -20,19 +20,11 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Module</th>
                             <th scope="row">Module</th>
-                            <td>
-                              {% if object.module %}
-                                <a href="{{ object.module.get_absolute_url }}">{{ object.module }}</a>
-                              {% else %}
-                                {{ None|placeholder }}
-                              {% endif %}
-                            </td>
+                            <td>{{ object.module|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -54,9 +46,7 @@
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Rear Port</th>
                             <th scope="row">Rear Port</th>
-                            <td>
-                                <a href="{{ object.rear_port.get_absolute_url }}">{{ object.rear_port }}</a>
-                            </td>
+                            <td>{{ object.rear_port|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Rear Port Position</th>
                             <th scope="row">Rear Port Position</th>
@@ -88,7 +78,7 @@
                         <tr>
                         <tr>
                             <th scope="row">Cable</th>
                             <th scope="row">Cable</th>
                             <td>
                             <td>
-                                <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                                {{ object.cable|linkify }}
                                 <a href="{% url 'dcim:frontport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                 <a href="{% url 'dcim:frontport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                 </a>
                                 </a>

+ 10 - 26
netbox/templates/dcim/inc/cable_termination.html

@@ -4,51 +4,35 @@
         {# Device component #}
         {# Device component #}
         <tr>
         <tr>
             <td>Device</td>
             <td>Device</td>
-            <td>
-                <a href="{{ termination.device.get_absolute_url }}">{{ termination.device }}</a>
-            </td>
+            <td>{{ termination.device|linkify }}</td>
         </tr>
         </tr>
-        {% if termination.device.site %}
         <tr>
         <tr>
             <td>Site</td>
             <td>Site</td>
-            <td>
-                <a href="{{ termination.device.site.get_absolute_url }}">{{ termination.device.site }}</a>
-            </td>
+            <td>{{ termination.device.site|linkify }}</td>
         </tr>
         </tr>
-        {% endif %}
         {% if termination.device.rack %}
         {% if termination.device.rack %}
-        <tr>
-            <td>Rack</td>
-            <td>
-                <a href="{{ termination.device.rack.get_absolute_url }}">{{ termination.device.rack }}</a>
-            </td>
-        </tr>
+            <tr>
+                <td>Rack</td>
+                <td>{{ termination.device.rack|linkify }}</td>
+            </tr>
         {% endif %}
         {% endif %}
         <tr>
         <tr>
             <td>Type</td>
             <td>Type</td>
-            <td>
-                {{ termination|meta:"verbose_name"|capfirst }}
-            </td>
+            <td>{{ termination|meta:"verbose_name"|capfirst }}</td>
         </tr>
         </tr>
         <tr>
         <tr>
             <td>Component</td>
             <td>Component</td>
-            <td>
-                <a href="{{ termination.get_absolute_url }}">{{ termination }}</a>
-            </td>
+            <td>{{ termination|linkify }}</td>
         </tr>
         </tr>
     {% else %}
     {% else %}
         {# Circuit termination #}
         {# Circuit termination #}
         <tr>
         <tr>
             <td>Provider</td>
             <td>Provider</td>
-            <td>
-                <a href="{{ termination.circuit.provider.get_absolute_url }}">{{ termination.circuit.provider }}</a>
-            </td>
+            <td>{{ termination.circuit.provider|linkify }}</td>
         </tr>
         </tr>
         <tr>
         <tr>
             <td>Circuit</td>
             <td>Circuit</td>
-            <td>
-                <a href="{{ termination.circuit.get_absolute_url }}">{{ termination.circuit }}</a> ({{ termination }})
-            </td>
+            <td>{{ termination.|linkify }} ({{ termination }})</td>
         </tr>
         </tr>
     {% endif %}
     {% endif %}
 </table>
 </table>

+ 2 - 2
netbox/templates/dcim/inc/cabletermination.html

@@ -6,9 +6,9 @@
             {{ termination.parent_object }}
             {{ termination.parent_object }}
         </a>
         </a>
     {% else %}
     {% else %}
-        <a href="{{ termination.parent_object.get_absolute_url }}">{{ termination.parent_object }}</a>
+        {{ termination.parent_object|linkify }}
     {% endif %}
     {% endif %}
 </td>
 </td>
 <td>
 <td>
-    <a href="{{ termination.get_absolute_url }}">{{ termination }}</a>
+    {{ termination|linkify }}
 </td>
 </td>

+ 2 - 2
netbox/templates/dcim/inc/endpoint_connection.html

@@ -1,7 +1,7 @@
 {% if path.destination_id %}
 {% if path.destination_id %}
     {% with endpoint=path.destination %}
     {% with endpoint=path.destination %}
-        <td><a href="{{ endpoint.parent_object.get_absolute_url }}">{{ endpoint.parent_object }}</a></td>
-        <td><a href="{{ endpoint.get_absolute_url }}">{{ endpoint }}</a></td>
+        <td>{{ endpoint.parent_object|linkify }}</td>
+        <td>{{ endpoint|linkify }}</td>
     {% endwith %}
     {% endwith %}
 {% else %}
 {% else %}
     <td colspan="2" class="text-muted">Not connected</td>
     <td colspan="2" class="text-muted">Not connected</td>

+ 2 - 6
netbox/templates/dcim/inc/interface_vlans_table.html

@@ -8,9 +8,7 @@
     {% with tagged_vlans=obj.tagged_vlans.all %}
     {% with tagged_vlans=obj.tagged_vlans.all %}
         {% if obj.untagged_vlan and obj.untagged_vlan not in tagged_vlans %}
         {% if obj.untagged_vlan and obj.untagged_vlan not in tagged_vlans %}
             <tr>
             <tr>
-                <td>
-                    <a href="{{ obj.untagged_vlan.get_absolute_url }}">{{ obj.untagged_vlan.vid }}</a>
-                </td>
+                <td>{{ obj.untagged_vlan|linkify:"vid" }}</td>
                 <td>{{ obj.untagged_vlan.name }}</td>
                 <td>{{ obj.untagged_vlan.name }}</td>
                 <td>
                 <td>
                     <input type="radio" name="untagged_vlan" value="{{ obj.untagged_vlan.pk }}" checked="checked" />
                     <input type="radio" name="untagged_vlan" value="{{ obj.untagged_vlan.pk }}" checked="checked" />
@@ -22,9 +20,7 @@
         {% endif %}
         {% endif %}
         {% for vlan in tagged_vlans %}
         {% for vlan in tagged_vlans %}
             <tr>
             <tr>
-                <td>
-                    <a href="{{ vlan.get_absolute_url }}">{{ vlan.vid }}</a>
-                </td>
+                <td>{{ vlan|linkify:"vid" }}</td>
                 <td>{{ vlan.name }}</td>
                 <td>{{ vlan.name }}</td>
                 <td>
                 <td>
                     <input type="radio" name="untagged_vlan" value="{{ vlan.pk }}"{% if vlan == obj.untagged_vlan %} checked="checked"{% endif %} />
                     <input type="radio" name="untagged_vlan" value="{{ vlan.pk }}"{% if vlan == obj.untagged_vlan %} checked="checked"{% endif %} />

+ 1 - 1
netbox/templates/dcim/inc/nonracked_devices.html

@@ -21,7 +21,7 @@
             <td>{{ device.device_role }}</td>
             <td>{{ device.device_role }}</td>
             <td>{{ device.device_type }}</td>
             <td>{{ device.device_type }}</td>
             {% if device.parent_bay %}
             {% if device.parent_bay %}
-                <td><a href="{{ device.parent_bay.device.get_absolute_url }}">{{ device.parent_bay.device }}</a></td>
+                <td>{{ device.parent_bay.device|linkify }}</td>
                 <td>{{ device.parent_bay }}</td>
                 <td>{{ device.parent_bay }}</td>
             {% else %}
             {% else %}
                 <td colspan="2" class="text-muted">&mdash;</td>
                 <td colspan="2" class="text-muted">&mdash;</td>

+ 3 - 13
netbox/templates/dcim/inc/panels/inventory_items.html

@@ -15,19 +15,9 @@
       <tbody>
       <tbody>
         {% for item in object.inventory_items.all %}
         {% for item in object.inventory_items.all %}
           <tr>
           <tr>
-            <td>
-              <a href="{{ item.get_absolute_url }}">{{ item.name }}</a>
-            </td>
-            <td>
-              {{ item.label|placeholder }}
-            </td>
-            <td>
-              {% if item.role %}
-                <a href="{{ item.role.get_absolute_url }}">{{ item.role }}</a>
-              {% else %}
-                <span class="text-muted">&mdash;</span>
-              {% endif %}
-            </td>
+            <td>{{ item|linkify:"name" }}</td>
+            <td>{{ item.label|placeholder }}</td>
+            <td>{{ item.role|linkify|placeholder }}</td>
             <td class="text-end noprint">
             <td class="text-end noprint">
               {% if perms.dcim.change_inventoryitem %}
               {% if perms.dcim.change_inventoryitem %}
                 <a href="{% url 'dcim:inventoryitem_edit' pk=item.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-warning btn-sm lh-1" title="Edit">
                 <a href="{% url 'dcim:inventoryitem_edit' pk=item.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-warning btn-sm lh-1" title="Edit">

+ 20 - 74
netbox/templates/dcim/interface.html

@@ -30,19 +30,11 @@
                     <table class="table table-hover">
                     <table class="table table-hover">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Module</th>
                             <th scope="row">Module</th>
-                            <td>
-                              {% if object.module %}
-                                <a href="{{ object.module.get_absolute_url }}">{{ object.module }}</a>
-                              {% else %}
-                                {{ None|placeholder }}
-                              {% endif %}
-                            </td>
+                            <td>{{ object.module|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -74,33 +66,15 @@
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Parent</th>
                             <th scope="row">Parent</th>
-                            <td>
-                                {% if object.parent %}
-                                    <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.parent|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Bridge</th>
                             <th scope="row">Bridge</th>
-                            <td>
-                                {% if object.bridge %}
-                                    <a href="{{ object.bridge.get_absolute_url }}">{{ object.bridge }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.bridge|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">LAG</th>
                             <th scope="row">LAG</th>
-                            <td>
-                                {% if object.lag%}
-                                    <a href="{{ object.lag.get_absolute_url }}">{{ object.lag }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.lag|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Description</th>
                             <th scope="row">Description</th>
@@ -128,13 +102,7 @@
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">VRF</th>
                             <th scope="row">VRF</th>
-                            <td>
-                                {% if object.vrf %}
-                                    <a href="{{ object.vrf.get_absolute_url }}">{{ object.vrf }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.vrf|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                     </table>
                     </table>
                 </div>
                 </div>
@@ -170,7 +138,7 @@
                             <tr>
                             <tr>
                                 <th scope="row">Cable</th>
                                 <th scope="row">Cable</th>
                                 <td>
                                 <td>
-                                    <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                                    {{ object.cable|linkify }}
                                     <a href="{% url 'dcim:interface_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <a href="{% url 'dcim:interface_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                         <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                         <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     </a>
                                     </a>
@@ -180,15 +148,11 @@
                                 {% with iface=object.connected_endpoint %}
                                 {% with iface=object.connected_endpoint %}
                                     <tr>
                                     <tr>
                                         <th scope="row">Device</th>
                                         <th scope="row">Device</th>
-                                        <td>
-                                            <a href="{{ iface.device.get_absolute_url }}">{{ iface.device }}</a>
-                                        </td>
+                                        <td>{{ iface.device|linkify }}</td>
                                     </tr>
                                     </tr>
                                     <tr>
                                     <tr>
                                         <th scope="row">Name</th>
                                         <th scope="row">Name</th>
-                                        <td>
-                                            <a href="{{ iface.get_absolute_url }}">{{ iface.name }}</a>
-                                        </td>
+                                        <td>{{ iface|linkify:"name" }}</td>
                                     </tr>
                                     </tr>
                                     <tr>
                                     <tr>
                                         <th scope="row">Type</th>
                                         <th scope="row">Type</th>
@@ -196,13 +160,7 @@
                                     </tr>
                                     </tr>
                                     <tr>
                                     <tr>
                                         <th scope="row">LAG</th>
                                         <th scope="row">LAG</th>
-                                        <td>
-                                            {% if iface.lag%}
-                                                <a href="{{ iface.lag.get_absolute_url }}">{{ iface.lag }}</a>
-                                            {% else %}
-                                                <span class="text-muted">None</span>
-                                            {% endif %}
-                                        </td>
+                                        <td>{{ iface.lag|linkify|placeholder }}</td>
                                     </tr>
                                     </tr>
                                     <tr>
                                     <tr>
                                         <th scope="row">Description</th>
                                         <th scope="row">Description</th>
@@ -225,11 +183,11 @@
                                 {% with ct=object.connected_endpoint %}
                                 {% with ct=object.connected_endpoint %}
                                     <tr>
                                     <tr>
                                         <th scope="row">Provider</th>
                                         <th scope="row">Provider</th>
-                                        <td><a href="{{ ct.circuit.provider.get_absolute_url }}">{{ ct.circuit.provider }}</a></td>
+                                        <td>{{ ct.circuit.provider|linkify }}</td>
                                     </tr>
                                     </tr>
                                     <tr>
                                     <tr>
                                         <th scope="row">Circuit</th>
                                         <th scope="row">Circuit</th>
-                                        <td><a href="{{ ct.circuit.get_absolute_url }}">{{ ct.circuit }}</a></td>
+                                        <td>{{ ct.circuit|linkify }}</td>
                                     </tr>
                                     </tr>
                                     <tr>
                                     <tr>
                                         <th scope="row">Side</th>
                                         <th scope="row">Side</th>
@@ -253,7 +211,7 @@
                             <tr>
                             <tr>
                                 <th scope="row">Wireless Link</th>
                                 <th scope="row">Wireless Link</th>
                                 <td>
                                 <td>
-                                    <a href="{{ object.wireless_link.get_absolute_url }}">{{ object.wireless_link }}</a>
+                                    {{ object.wireless_link|linkify }}
                                     <a href="{% url 'dcim:interface_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <a href="{% url 'dcim:interface_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                         <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                         <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     </a>
                                     </a>
@@ -262,15 +220,11 @@
                             {% with peer_interface=object.connected_endpoint %}
                             {% with peer_interface=object.connected_endpoint %}
                                 <tr>
                                 <tr>
                                     <th scope="row">Device</th>
                                     <th scope="row">Device</th>
-                                    <td>
-                                        <a href="{{ peer_interface.device.get_absolute_url }}">{{ peer_interface.device }}</a>
-                                    </td>
+                                    <td>{{ peer_interface.device|linkify }}</td>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
                                     <th scope="row">Name</th>
                                     <th scope="row">Name</th>
-                                    <td>
-                                        <a href="{{ peer_interface.get_absolute_url }}">{{ peer_interface }}</a>
-                                    </td>
+                                    <td>{{ peer_interface|linkify }}</td>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
                                     <th scope="row">Type</th>
                                     <th scope="row">Type</th>
@@ -409,14 +363,12 @@
                                     <tr>
                                     <tr>
                                         <td>
                                         <td>
                                             {% if wlan.group %}
                                             {% if wlan.group %}
-                                              <a href="{{ wlan.group.get_absolute_url }}">{{ wlan.group }}</a>
+                                              {{ wlan.group|linkify }}
                                             {% else %}
                                             {% else %}
                                               &mdash;
                                               &mdash;
                                             {% endif %}
                                             {% endif %}
                                         </td>
                                         </td>
-                                        <td>
-                                            <a href="{{ wlan.get_absolute_url }}">{{ wlan.ssid }}</a>
-                                        </td>
+                                        <td>{{ wlan|linkify:"ssid" }}</td>
                                     </tr>
                                     </tr>
                                 {% empty %}
                                 {% empty %}
                                     <tr>
                                     <tr>
@@ -443,15 +395,9 @@
                             <tbody>
                             <tbody>
                                 {% for member in object.member_interfaces.all %}
                                 {% for member in object.member_interfaces.all %}
                                     <tr>
                                     <tr>
-                                        <td>
-                                            <a href="{{ member.device.get_absolute_url }}">{{ member.device }}</a>
-                                        </td>
-                                        <td>
-                                            <a href="{{ member.get_absolute_url }}">{{ member }}</a>
-                                        </td>
-                                        <td>
-                                            {{ member.get_type_display }}
-                                        </td>
+                                        <td>{{ member.device|linkify }}</td>
+                                        <td>{{ member|linkify }}</td>
+                                        <td>{{ member.get_type_display }}</td>
                                     </tr>
                                     </tr>
                                 {% empty %}
                                 {% empty %}
                                     <tr>
                                     <tr>

+ 5 - 31
netbox/templates/dcim/inventoryitem.html

@@ -18,19 +18,11 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Parent Item</th>
                             <th scope="row">Parent Item</th>
-                            <td>
-                                {% if object.parent %}
-                                    <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-                                {% else %}
-                                    <span class="text-muted">&mdash;</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.parent|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -42,33 +34,15 @@
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Role</th>
                             <th scope="row">Role</th>
-                            <td>
-                                {% if object.role %}
-                                    <a href="{{ object.role.get_absolute_url }}">{{ object.role }}</a>
-                                {% else %}
-                                    <span class="text-muted">&mdash;</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.role|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Component</th>
                             <th scope="row">Component</th>
-                            <td>
-                                {% if object.component %}
-                                    <a href="{{ object.component.get_absolute_url }}">{{ object.component }}</a>
-                                {% else %}
-                                    <span class="text-muted">&mdash;</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.component|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Manufacturer</th>
                             <th scope="row">Manufacturer</th>
-                            <td>
-                                {% if object.manufacturer %}
-                                    <a href="{{ object.manufacturer.get_absolute_url }}">{{ object.manufacturer }}</a>
-                                {% else %}
-                                    <span class="text-muted">&mdash;</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.manufacturer|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Part ID</th>
                             <th scope="row">Part ID</th>

+ 9 - 19
netbox/templates/dcim/location.html

@@ -6,7 +6,7 @@
 {% block breadcrumbs %}
 {% block breadcrumbs %}
   {{ block.super }}
   {{ block.super }}
   {% for location in object.get_ancestors %}
   {% for location in object.get_ancestors %}
-    <li class="breadcrumb-item"><a href="{{ location.get_absolute_url }}">{{ location }}</a></li>
+    <li class="breadcrumb-item">{{ location|linkify }}</li>
   {% endfor %}
   {% endfor %}
 {% endblock %}
 {% endblock %}
 
 
@@ -37,31 +37,21 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Site</th>
             <th scope="row">Site</th>
-            <td><a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a></td>
+            <td>{{ object.site|linkify }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Parent</th>
             <th scope="row">Parent</th>
+            <td>{{ object.parent|linkify|placeholder }}</td>
+          </tr>
+          <tr>
+            <th scope="row">Tenant</th>
             <td>
             <td>
-              {% if object.parent %}
-                <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-              {% else %}
-                <span class="text-muted">&mdash;</span>
+              {% if object.tenant.group %}
+                {{ object.tenant.group|linkify }} /
               {% endif %}
               {% endif %}
+              {{ object.tenant|linkify|placeholder }}
             </td>
             </td>
           </tr>
           </tr>
-          <tr>
-              <th scope="row">Tenant</th>
-              <td>
-                  {% if object.tenant %}
-                      {% if object.tenant.group %}
-                          <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                      {% endif %}
-                      <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                  {% else %}
-                      <span class="text-muted">None</span>
-                  {% endif %}
-              </td>
-          </tr>
           <tr>
           <tr>
             <th scope="row">Racks</th>
             <th scope="row">Racks</th>
             <td>
             <td>

+ 3 - 9
netbox/templates/dcim/module.html

@@ -19,21 +19,15 @@
         <table class="table table-hover attr-table">
         <table class="table table-hover attr-table">
           <tr>
           <tr>
             <th scope="row">Device</th>
             <th scope="row">Device</th>
-            <td>
-              <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-            </td>
+            <td>{{ object.device|linkify }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Device Type</th>
             <th scope="row">Device Type</th>
-            <td>
-              <a href="{{ object.device.device_type.get_absolute_url }}">{{ object.device.device_type }}</a>
-            </td>
+            <td>{{ object.device.device_type|linkify }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Module Type</th>
             <th scope="row">Module Type</th>
-            <td>
-              <a href="{{ object.module_type.get_absolute_url }}">{{ object.module_type }}</a>
-            </td>
+            <td>{{ object.module_type|linkify }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Serial Number</th>
             <th scope="row">Serial Number</th>

+ 2 - 6
netbox/templates/dcim/modulebay.html

@@ -54,15 +54,11 @@
             <table class="table table-hover attr-table">
             <table class="table table-hover attr-table">
               <tr>
               <tr>
                 <th scope="row">Manufacturer</th>
                 <th scope="row">Manufacturer</th>
-                <td>
-                  <a href="{{ module.module_type.manufacturer.get_absolute_url }}">{{ module.module_type.manufacturer }}</a>
-                </td>
+                <td>{{ module.module_type.manufacturer|linkify }}</td>
               </tr>
               </tr>
               <tr>
               <tr>
                 <th scope="row">Module Type</th>
                 <th scope="row">Module Type</th>
-                <td>
-                  <a href="{{ module.get_absolute_url }}">{{ module.module_type }}</a>
-                </td>
+                <td>{{ module.module_type|linkify }}</td>
               </tr>
               </tr>
             </table>
             </table>
           {% endwith %}
           {% endwith %}

+ 1 - 1
netbox/templates/dcim/moduletype.html

@@ -12,7 +12,7 @@
           <table class="table table-hover attr-table">
           <table class="table table-hover attr-table">
             <tr>
             <tr>
               <td>Manufacturer</td>
               <td>Manufacturer</td>
-              <td><a href="{{ object.manufacturer.get_absolute_url }}">{{ object.manufacturer }}</a></td>
+              <td>{{ object.manufacturer|linkify }}</td>
             </tr>
             </tr>
             <tr>
             <tr>
               <td>Model Name</td>
               <td>Model Name</td>

+ 1 - 7
netbox/templates/dcim/platform.html

@@ -37,13 +37,7 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Manufacturer</th>
             <th scope="row">Manufacturer</th>
-            <td>
-              {% if object.manufacturer %}
-                <a href="{{ object.manufacturer.get_absolute_url }}">{{ object.manufacturer }}</a>
-              {% else %}
-                <span class="text-muted">None</span>
-              {% endif %}
-            </td>
+            <td>{{ object.manufacturer|linkify|placeholder }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">NAPALM Driver</th>
             <th scope="row">NAPALM Driver</th>

+ 6 - 18
netbox/templates/dcim/powerfeed.html

@@ -24,19 +24,11 @@
                 <table class="table table-hover attr-table">
                 <table class="table table-hover attr-table">
                     <tr>
                     <tr>
                         <th scope="row">Power Panel</th>
                         <th scope="row">Power Panel</th>
-                        <td>
-                            <a href="{{ object.power_panel.get_absolute_url }}">{{ object.power_panel }}</a>
-                        </td>
+                        <td>{{ object.power_panel|linkify }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Rack</th>
                         <th scope="row">Rack</th>
-                        <td>
-                            {% if object.rack %}
-                                <a href="{{ object.rack.get_absolute_url }}">{{ object.rack }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.rack|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Type</th>
                         <th scope="row">Type</th>
@@ -50,7 +42,7 @@
                         <th scope="row">Connected Device</th>
                         <th scope="row">Connected Device</th>
                         <td>
                         <td>
                             {% if object.connected_endpoint %}
                             {% if object.connected_endpoint %}
-                                <a href="{{ object.connected_endpoint.device.get_absolute_url }}">{{ object.connected_endpoint.device }}</a> ({{ object.connected_endpoint }})
+                                {{ object.connected_endpoint.device|linkify }} ({{ object.connected_endpoint }})
                             {% else %}
                             {% else %}
                                 <span class="text-muted">None</span>
                                 <span class="text-muted">None</span>
                             {% endif %}
                             {% endif %}
@@ -122,7 +114,7 @@
                     <tr>
                     <tr>
                         <th scope="row">Cable</th>
                         <th scope="row">Cable</th>
                         <td>
                         <td>
-                            <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                            {{ object.cable|linkify }}
                             <a href="{% url 'dcim:powerfeed_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                             <a href="{% url 'dcim:powerfeed_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                 <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                 <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                             </a>
                             </a>
@@ -131,15 +123,11 @@
                     {% if object.connected_endpoint %}
                     {% if object.connected_endpoint %}
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.connected_endpoint.device.get_absolute_url }}">{{ object.connected_endpoint.device }}</a>
-                            </td>
+                            <td>{{ object.connected_endpoint.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
-                            <td>
-                                <a href="{{ object.connected_endpoint.get_absolute_url }}">{{ object.connected_endpoint.name }}</a>
-                            </td>
+                            <td>{{ object.connected_endpoint|linkify:"name" }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Type</th>
                             <th scope="row">Type</th>

+ 5 - 17
netbox/templates/dcim/poweroutlet.html

@@ -20,19 +20,11 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Module</th>
                             <th scope="row">Module</th>
-                            <td>
-                              {% if object.module %}
-                                <a href="{{ object.module.get_absolute_url }}">{{ object.module }}</a>
-                              {% else %}
-                                {{ None|placeholder }}
-                              {% endif %}
-                            </td>
+                            <td>{{ object.module|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -80,7 +72,7 @@
                         <tr>
                         <tr>
                             <th scope="row">Cable</th>
                             <th scope="row">Cable</th>
                             <td>
                             <td>
-                                <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                                {{ object.cable|linkify }}
                                 <a href="{% url 'dcim:poweroutlet_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                 <a href="{% url 'dcim:poweroutlet_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                 </a>
                                 </a>
@@ -89,15 +81,11 @@
                         {% if object.connected_endpoint %}
                         {% if object.connected_endpoint %}
                             <tr>
                             <tr>
                                 <th scope="row">Device</th>
                                 <th scope="row">Device</th>
-                                <td>
-                                    <a href="{{ object.connected_endpoint.device.get_absolute_url }}">{{ object.connected_endpoint.device }}</a>
-                                </td>
+                                <td>{{ object.connected_endpoint.device|linkify }}</td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <th scope="row">Name</th>
                                 <th scope="row">Name</th>
-                                <td>
-                                    <a href="{{ object.connected_endpoint.get_absolute_url }}">{{ object.connected_endpoint.name }}</a>
-                                </td>
+                                <td>{{ object.connected_endpoint|linkify:"name" }}</td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <th scope="row">Type</th>
                                 <th scope="row">Type</th>

+ 3 - 11
netbox/templates/dcim/powerpanel.html

@@ -7,7 +7,7 @@
   {{ block.super }}
   {{ block.super }}
   <li class="breadcrumb-item"><a href="{% url 'dcim:powerpanel_list' %}?site_id={{ object.site.pk }}">{{ object.site }}</a></li>
   <li class="breadcrumb-item"><a href="{% url 'dcim:powerpanel_list' %}?site_id={{ object.site.pk }}">{{ object.site }}</a></li>
   {% if object.location %}
   {% if object.location %}
-    <li class="breadcrumb-item"><a href="{{ object.location.get_absolute_url }}">{{ object.location }}</a></li>
+    <li class="breadcrumb-item">{{ object.location|linkify }}</li>
   {% endif %}
   {% endif %}
 {% endblock %}
 {% endblock %}
 
 
@@ -22,19 +22,11 @@
                 <table class="table table-hover attr-table">
                 <table class="table table-hover attr-table">
                     <tr>
                     <tr>
                         <th scope="row">Site</th>
                         <th scope="row">Site</th>
-                        <td>
-                            <a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a>
-                        </td>
+                        <td>{{ object.site|linkify }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Location</th>
                         <th scope="row">Location</th>
-                        <td>
-                            {% if object.location %}
-                                <a href="{{ object.location.get_absolute_url }}">{{ object.location }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.location|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                 </table>
                 </table>
             </div>
             </div>

+ 5 - 17
netbox/templates/dcim/powerport.html

@@ -20,19 +20,11 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Module</th>
                             <th scope="row">Module</th>
-                            <td>
-                              {% if object.module %}
-                                <a href="{{ object.module.get_absolute_url }}">{{ object.module }}</a>
-                              {% else %}
-                                {{ None|placeholder }}
-                              {% endif %}
-                            </td>
+                            <td>{{ object.module|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -80,7 +72,7 @@
                         <tr>
                         <tr>
                             <th scope="row">Cable</th>
                             <th scope="row">Cable</th>
                             <td>
                             <td>
-                                <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                                {{ object.cable|linkify }}
                                 <a href="{% url 'dcim:powerport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                 <a href="{% url 'dcim:powerport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                 </a>
                                 </a>
@@ -89,15 +81,11 @@
                         {% if object.connected_endpoint %}
                         {% if object.connected_endpoint %}
                             <tr>
                             <tr>
                                 <th scope="row">Device</th>
                                 <th scope="row">Device</th>
-                                <td>
-                                    <a href="{{ object.connected_endpoint.device.get_absolute_url }}">{{ object.connected_endpoint.device }}</a>
-                                </td>
+                                <td>{{ object.connected_endpoint.device|linkify }}</td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <th scope="row">Name</th>
                                 <th scope="row">Name</th>
-                                <td>
-                                    <a href="{{ object.connected_endpoint.get_absolute_url }}">{{ object.connected_endpoint.name }}</a>
-                                </td>
+                                <td>{{ object.connected_endpoint|linkify:"name" }}</td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
                                 <th scope="row">Type</th>
                                 <th scope="row">Type</th>

+ 14 - 40
netbox/templates/dcim/rack.html

@@ -39,9 +39,9 @@
                         <th scope="row">Site</th>
                         <th scope="row">Site</th>
                         <td>
                         <td>
                             {% if object.site.region %}
                             {% if object.site.region %}
-                                <a href="{{ object.site.region.get_absolute_url }}">{{ object.site.region }}</a> /
+                                {{ object.site.region|linkify }} /
                             {% endif %}
                             {% endif %}
-                            <a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a>
+                            {{ object.site|linkify }}
                         </td>
                         </td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
@@ -49,9 +49,9 @@
                         <td>
                         <td>
                             {% if object.location %}
                             {% if object.location %}
                                 {% for location in object.location.get_ancestors %}
                                 {% for location in object.location.get_ancestors %}
-                                    <a href="{{ location.get_absolute_url }}">{{ location }}</a> /
+                                    {{ location|linkify }} /
                                 {% endfor %}
                                 {% endfor %}
-                                <a href="{{ object.location.get_absolute_url }}">{{ object.location }}</a>
+                                {{ object.location|linkify }}
                             {% else %}
                             {% else %}
                                 <span class="text-muted">None</span>
                                 <span class="text-muted">None</span>
                             {% endif %}
                             {% endif %}
@@ -64,14 +64,10 @@
                     <tr>
                     <tr>
                         <th scope="row">Tenant</th>
                         <th scope="row">Tenant</th>
                         <td>
                         <td>
-                            {% if object.tenant %}
-                                {% if object.tenant.group %}
-                                    <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                                {% endif %}
-                                <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
+                            {% if object.tenant.group %}
+                                {{ object.tenant.group|linkify }} /
                             {% endif %}
                             {% endif %}
+                            {{ object.tenant|linkify|placeholder }}
                         </td>
                         </td>
                     </tr>
                     </tr>
                      <tr>
                      <tr>
@@ -80,13 +76,7 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Role</th>
                         <th scope="row">Role</th>
-                        <td>
-                            {% if object.role %}
-                                <a href="{{ object.role.get_absolute_url }}">{{ object.role }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.role|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Serial Number</th>
                         <th scope="row">Serial Number</th>
@@ -179,18 +169,10 @@
                         </tr>
                         </tr>
                         {% for powerfeed in power_feeds %}
                         {% for powerfeed in power_feeds %}
                             <tr>
                             <tr>
-                                <td>
-                                    <a href="{{ powerfeed.power_panel.get_absolute_url }}">{{ powerfeed.power_panel.name }}</a>
-
-                                <td>
-                                    <a href="{{ powerfeed.get_absolute_url }}">{{ powerfeed.name }}</a>
-                                </td>
-                                <td>
-                                    {% badge powerfeed.get_status_display bg_color=powerfeed.get_status_color %}
-                                </td>
-                                <td>
-                                    {% badge powerfeed.get_type_display bg_color=powerfeed.get_type_color %}
-                                </td>
+                                <td>{{ powerfeed.power_panel|linkify }}</td>
+                                <td>{{ powerfeed|linkify }}</td>
+                                <td>{% badge powerfeed.get_status_display bg_color=powerfeed.get_status_color %}</td>
+                                <td>{% badge powerfeed.get_type_display bg_color=powerfeed.get_type_color %}</td>
                                 {% with power_port=powerfeed.connected_endpoint %}
                                 {% with power_port=powerfeed.connected_endpoint %}
                                     {% if power_port %}
                                     {% if power_port %}
                                         <td>{% utilization_graph power_port.get_power_draw.allocated|percentage:powerfeed.available_power %}</td>
                                         <td>{% utilization_graph power_port.get_power_draw.allocated|percentage:powerfeed.available_power %}</td>
@@ -220,16 +202,8 @@
                     </tr>
                     </tr>
                     {% for resv in reservations %}
                     {% for resv in reservations %}
                         <tr>
                         <tr>
-                            <td>
-                                <a href="{{ resv.get_absolute_url }}">{{ resv.unit_list }}</a>
-                            </td>
-                            <td>
-                                {% if resv.tenant %}
-                                    <a href="{{ resv.tenant.get_absolute_url }}">{{ resv.tenant }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ resv|linkify:"unit_list" }}</td>
+                            <td>{{ resv.tenant|linkify|placeholder }}</td>
                             <td>
                             <td>
                                 {{ resv.description }}<br />
                                 {{ resv.description }}<br />
                                 <small>{{ resv.user }} &middot; {{ resv.created|annotated_date }}</small>
                                 <small>{{ resv.user }} &middot; {{ resv.created|annotated_date }}</small>

+ 7 - 19
netbox/templates/dcim/rackreservation.html

@@ -24,26 +24,18 @@
                             <th scope="row">Site</th>
                             <th scope="row">Site</th>
                             <td>
                             <td>
                                 {% if rack.site.region %}
                                 {% if rack.site.region %}
-                                    <a href="{{ rack.site.region.get_absolute_url }}">{{ rack.site.region }}</a> /
+                                    {{ rack.site.region|linkify }} /
                                 {% endif %}
                                 {% endif %}
-                                <a href="{{ rack.site.get_absolute_url }}">{{ rack.site }}</a>
+                                {{ rack.site|linkify }}
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Location</th>
                             <th scope="row">Location</th>
-                            <td>
-                                {% if rack.location %}
-                                    <a href="{{ rack.location.get_absolute_url }}">{{ rack.location }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ rack.location|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Rack</th>
                             <th scope="row">Rack</th>
-                            <td>
-                                <a href="{{ rack.get_absolute_url }}">{{ rack }}</a>
-                            </td>
+                            <td>{{ rack|linkify }}</td>
                         </tr>
                         </tr>
                     {% endwith %}
                     {% endwith %}
                 </table>
                 </table>
@@ -62,14 +54,10 @@
                     <tr>
                     <tr>
                         <th scope="row">Tenant</th>
                         <th scope="row">Tenant</th>
                         <td>
                         <td>
-                            {% if object.tenant %}
-                                {% if object.tenant.group %}
-                                    <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                                {% endif %}
-                                <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
+                            {% if object.tenant.group %}
+                                {{ object.tenant.group|linkify }} /
                             {% endif %}
                             {% endif %}
+                            {{ object.tenant|linkify|placeholder }}
                         </td>
                         </td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>

+ 3 - 11
netbox/templates/dcim/rearport.html

@@ -20,19 +20,11 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Device</th>
                             <th scope="row">Device</th>
-                            <td>
-                                <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
-                            </td>
+                            <td>{{ object.device|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Module</th>
                             <th scope="row">Module</th>
-                            <td>
-                              {% if object.module %}
-                                <a href="{{ object.module.get_absolute_url }}">{{ object.module }}</a>
-                              {% else %}
-                                {{ None|placeholder }}
-                              {% endif %}
-                            </td>
+                            <td>{{ object.module|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Name</th>
                             <th scope="row">Name</th>
@@ -82,7 +74,7 @@
                         <tr>
                         <tr>
                             <th scope="row">Cable</th>
                             <th scope="row">Cable</th>
                             <td>
                             <td>
-                                <a href="{{ object.cable.get_absolute_url }}">{{ object.cable }}</a>
+                                {{ object.cable|linkify }}
                                 <a href="{% url 'dcim:rearport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                 <a href="{% url 'dcim:rearport_trace' pk=object.pk %}" class="btn btn-primary btn-sm lh-1" title="Trace">
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                     <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
                                 </a>
                                 </a>

+ 1 - 7
netbox/templates/dcim/region.html

@@ -37,13 +37,7 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Parent</th>
             <th scope="row">Parent</th>
-            <td>
-              {% if object.parent %}
-                <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-              {% else %}
-                <span class="text-muted">&mdash;</span>
-              {% endif %}
-            </td>
+            <td>{{ object.parent|linkify|placeholder }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Sites</th>
             <th scope="row">Sites</th>

+ 9 - 13
netbox/templates/dcim/site.html

@@ -30,9 +30,9 @@
             <td>
             <td>
               {% if object.region %}
               {% if object.region %}
                 {% for region in object.region.get_ancestors %}
                 {% for region in object.region.get_ancestors %}
-                  <a href="{{ region.get_absolute_url }}">{{ region }}</a> /
+                  {{ region|linkify }} /
                 {% endfor %}
                 {% endfor %}
-                <a href="{{ object.region.get_absolute_url }}">{{ object.region }}</a>
+                {{ object.region|linkify }}
               {% else %}
               {% else %}
                 <span class="text-muted">None</span>
                 <span class="text-muted">None</span>
               {% endif %}
               {% endif %}
@@ -43,9 +43,9 @@
             <td>
             <td>
               {% if object.group %}
               {% if object.group %}
                 {% for group in object.group.get_ancestors %}
                 {% for group in object.group.get_ancestors %}
-                  <a href="{{ group.get_absolute_url }}">{{ group }}</a> /
+                  {{ group|linkify }} /
                 {% endfor %}
                 {% endfor %}
-                <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
+                {{ object.group|linkify }}
               {% else %}
               {% else %}
                 <span class="text-muted">None</span>
                 <span class="text-muted">None</span>
               {% endif %}
               {% endif %}
@@ -58,14 +58,10 @@
           <tr>
           <tr>
             <th scope="row">Tenant</th>
             <th scope="row">Tenant</th>
             <td>
             <td>
-              {% if object.tenant %}
-                {% if object.tenant.group %}
-                  <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                {% endif %}
-                <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-              {% else %}
-                <span class="text-muted">None</span>
+              {% if object.tenant.group %}
+                {{ object.tenant.group|linkify }} /
               {% endif %}
               {% endif %}
+              {{ object.tenant|linkify|placeholder }}
             </td>
             </td>
           </tr>
           </tr>
           <tr>
           <tr>
@@ -242,7 +238,7 @@
                 <tr>
                 <tr>
                   <td>
                   <td>
                     {% for i in location.level|as_range %}<i class="mdi mdi-circle-small"></i>{% endfor %}
                     {% for i in location.level|as_range %}<i class="mdi mdi-circle-small"></i>{% endfor %}
-                    <a href="{{ location.get_absolute_url }}">{{ location }}</a>
+                    {{ location|linkify }}
                   </td>
                   </td>
                   <td>
                   <td>
                     <a href="{% url 'dcim:rack_list' %}?location_id={{ location.pk }}">{{ location.rack_count }}</a>
                     <a href="{% url 'dcim:rack_list' %}?location_id={{ location.pk }}">{{ location.rack_count }}</a>
@@ -281,7 +277,7 @@
               </tr>
               </tr>
             {% for asn in asns %}
             {% for asn in asns %}
               <tr>
               <tr>
-                <td><a href="{{ asn.get_absolute_url }}">{{ asn }}</a></td>
+                <td>{{ asn|linkify }}</td>
                 <td>{{ asn.description|placeholder }}</td>
                 <td>{{ asn.description|placeholder }}</td>
               </tr>
               </tr>
             {% endfor %}
             {% endfor %}

+ 1 - 7
netbox/templates/dcim/sitegroup.html

@@ -37,13 +37,7 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Parent</th>
             <th scope="row">Parent</th>
-            <td>
-              {% if object.parent %}
-                <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-              {% else %}
-                <span class="text-muted">&mdash;</span>
-              {% endif %}
-            </td>
+            <td>{{ object.parent|linkify|placeholder }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Sites</th>
             <th scope="row">Sites</th>

+ 2 - 2
netbox/templates/dcim/trace/circuit.html

@@ -1,5 +1,5 @@
 <div class="node">
 <div class="node">
-    <strong><a href="{{ circuit.get_absolute_url }}">{{ circuit }}</a></strong><br />
+    <strong>{{ circuit|linkify }}</strong><br />
     Circuit<br />
     Circuit<br />
-    <a href="{{ circuit.provider.get_absolute_url }}">{{ circuit.provider }}</a>
+    {{ circuit.provider|linkify }}
 </div>
 </div>

+ 4 - 4
netbox/templates/dcim/trace/device.html

@@ -1,11 +1,11 @@
 <div class="node">
 <div class="node">
-    <strong><a href="{{ device.get_absolute_url }}">{{ device }}</a></strong><br />
+    <strong>{{ device|linkify }}</strong><br />
     {{ device.device_type.manufacturer }} {{ device.device_type }}<br />
     {{ device.device_type.manufacturer }} {{ device.device_type }}<br />
-    <a href="{{ device.site.get_absolute_url }}">{{ device.site }}</a>
+    {{ device.site|linkify }}
     {% if device.location %}
     {% if device.location %}
-        / <a href="{{ device.location.get_absolute_url }}">{{ device.location }}</a>
+        / {{ device.location|linkify }}
     {% endif %}
     {% endif %}
     {% if device.rack %}
     {% if device.rack %}
-        / <a href="{{ device.rack.get_absolute_url }}">{{ device.rack }}</a>
+        / {{ device.rack|linkify }}
     {% endif %}
     {% endif %}
 </div>
 </div>

+ 1 - 1
netbox/templates/dcim/trace/object.html

@@ -1,3 +1,3 @@
 <div class="node">
 <div class="node">
-    <strong><a href="{{ object.get_absolute_url }}">{{ object }}</a></strong>
+    <strong>{{ object|linkify }}</strong>
 </div>
 </div>

+ 2 - 2
netbox/templates/dcim/trace/powerpanel.html

@@ -1,5 +1,5 @@
 <div class="node">
 <div class="node">
-    <strong><a href="{{ powerpanel.get_absolute_url }}">{{ powerpanel }}</a></strong><br />
+    <strong>{{ powerpanel|linkify }}</strong><br />
     Power Panel<br />
     Power Panel<br />
-    <a href="{{ powerpanel.site.get_absolute_url }}">{{ powerpanel.site }}</a>
+    {{ powerpanel.site|linkify }}
 </div>
 </div>

+ 1 - 1
netbox/templates/dcim/trace/termination.html

@@ -1,6 +1,6 @@
 {% load helpers %}
 {% load helpers %}
 <div class="termination{% if obj == termination %} active{% endif %}">
 <div class="termination{% if obj == termination %} active{% endif %}">
-    <strong><a href="{{ termination.get_absolute_url }}">{{ termination }}</a></strong><br />
+    <strong>{{ termination|linkify }}</strong><br />
     {{ termination|meta:"verbose_name"|bettertitle }}
     {{ termination|meta:"verbose_name"|bettertitle }}
     {% if termination.type %}
     {% if termination.type %}
         <small class="text-muted">{{ termination.get_type_display }}</small>
         <small class="text-muted">{{ termination.get_type_display }}</small>

+ 2 - 8
netbox/templates/dcim/virtualchassis.html

@@ -27,13 +27,7 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Master</th>
                         <th scope="row">Master</th>
-                        <td>
-                            {% if object.master %}
-                                <a href="{{ object.master.get_absolute_url }}">{{ object.master }}</a>
-                            {% else %}
-                                <span class="text-muted">&mdash;</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.master|linkify }}</td>
                     </tr>
                     </tr>
                 </table>
                 </table>
             </div>
             </div>
@@ -58,7 +52,7 @@
                     {% for vc_member in members %}
                     {% for vc_member in members %}
                         <tr{% if vc_member == device %} class="info"{% endif %}>
                         <tr{% if vc_member == device %} class="info"{% endif %}>
                             <td>
                             <td>
-                                <a href="{{ vc_member.get_absolute_url }}">{{ vc_member }}</a>
+                                {{ vc_member|linkify }}
                             </td>
                             </td>
                             <td>
                             <td>
                               {% badge vc_member.vc_position show_empty=True %}
                               {% badge vc_member.vc_position show_empty=True %}

+ 1 - 3
netbox/templates/dcim/virtualchassis_edit.html

@@ -51,9 +51,7 @@
                       {% endfor %}
                       {% endfor %}
                       {% with device=form.instance virtual_chassis=vc_form.instance %}
                       {% with device=form.instance virtual_chassis=vc_form.instance %}
                           <tr>
                           <tr>
-                              <td>
-                                  <a href="{{ device.get_absolute_url }}">{{ device }}</a>
-                              </td>
+                              <td>{{ device|linkify }}</td>
                               <td>{{ device.pk }}</td>
                               <td>{{ device.pk }}</td>
                               <td>
                               <td>
                                   {% if device.rack %}
                                   {% if device.rack %}

+ 1 - 1
netbox/templates/extras/configcontext.html

@@ -56,7 +56,7 @@
                           <td>
                           <td>
                             <ul class="list-unstyled mb-0">
                             <ul class="list-unstyled mb-0">
                               {% for object in objects %}
                               {% for object in objects %}
-                                <li><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
+                                <li>{{ object|linkify }}</li>
                               {% empty %}
                               {% empty %}
                                 <li class="text-muted">None</li>
                                 <li class="text-muted">None</li>
                               {% endfor %}
                               {% endfor %}

+ 1 - 1
netbox/templates/extras/imageattachment_edit.html

@@ -10,7 +10,7 @@
       </label>
       </label>
       <div class="col-sm-9">
       <div class="col-sm-9">
         <div class="form-control-plaintext">
         <div class="form-control-plaintext">
-          <a href="{{ object.parent.get_absolute_url }}" class="">{{ object.parent }}</a>
+          {{ object.parent|linkify }}
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>

+ 3 - 9
netbox/templates/extras/journalentry.html

@@ -18,21 +18,15 @@
                     <table class="table table-hover attr-table">
                     <table class="table table-hover attr-table">
                         <tr>
                         <tr>
                             <th scope="row">Object</th>
                             <th scope="row">Object</th>
-                            <td>
-                                <a href="{{ object.assigned_object.get_absolute_url }}">{{ object.assigned_object }}</a>
-                            </td>
+                            <td>{{ object.assigned_object|linkify }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Created</th>
                             <th scope="row">Created</th>
-                            <td>
-                                {{ object.created|annotated_date }}
-                            </td>
+                            <td>{{ object.created|annotated_date }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Created By</th>
                             <th scope="row">Created By</th>
-                            <td>
-                                {{ object.created_by }}
-                            </td>
+                            <td>{{ object.created_by }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Kind</th>
                             <th scope="row">Kind</th>

+ 1 - 1
netbox/templates/extras/object_configcontext.html

@@ -43,7 +43,7 @@
                         <div class="float-end">
                         <div class="float-end">
                             <span class="text-muted">{{ context.weight }}</span>
                             <span class="text-muted">{{ context.weight }}</span>
                         </div>
                         </div>
-                        <a href="{{ context.get_absolute_url }}"><strong>{{ context.name }}</strong></a>
+                        <strong>{{ context|linkify:"name" }}"></strong>
                         {% if context.description %}
                         {% if context.description %}
                             <br /><small>{{ context.description }}</small>
                             <br /><small>{{ context.description }}</small>
                         {% endif %}
                         {% endif %}

+ 1 - 1
netbox/templates/extras/objectchange.html

@@ -61,7 +61,7 @@
                         <th scope="row">Object</th>
                         <th scope="row">Object</th>
                         <td>
                         <td>
                             {% if object.changed_object and object.changed_object.get_absolute_url %}
                             {% if object.changed_object and object.changed_object.get_absolute_url %}
-                                <a href="{{ object.changed_object.get_absolute_url }}">{{ object.changed_object }}</a>
+                                {{ object.changed_object|linkify }}
                             {% else %}
                             {% else %}
                                 {{ object.object_repr }}
                                 {{ object.object_repr }}
                             {% endif %}
                             {% endif %}

+ 1 - 3
netbox/templates/inc/panels/contacts.html

@@ -14,9 +14,7 @@
           </tr>
           </tr>
           {% for contact in contacts %}
           {% for contact in contacts %}
             <tr>
             <tr>
-              <td>
-                <a href="{{ contact.contact.get_absolute_url }}">{{ contact.contact }}</a>
-              </td>
+              <td>{{ contact.contact|linkify }}</td>
               <td>{{ contact.role|placeholder }}</td>
               <td>{{ contact.role|placeholder }}</td>
               <td>{{ contact.get_priority_display|placeholder }}</td>
               <td>{{ contact.get_priority_display|placeholder }}</td>
               <td class="text-end noprint">
               <td class="text-end noprint">

+ 2 - 2
netbox/templates/inc/panels/custom_fields.html

@@ -27,11 +27,11 @@
                                 {% elif field.type == 'multiselect' and value %}
                                 {% elif field.type == 'multiselect' and value %}
                                     {{ value|join:", " }}
                                     {{ value|join:", " }}
                                 {% elif field.type == 'object' and value %}
                                 {% elif field.type == 'object' and value %}
-                                    <a href="{{ value.get_absolute_url }}">{{ value }}</a>
+                                    {{ value|linkify }}
                                 {% elif field.type == 'multiobject' and value %}
                                 {% elif field.type == 'multiobject' and value %}
                                     <ul>
                                     <ul>
                                       {% for obj in value %}
                                       {% for obj in value %}
-                                        <li><a href="{{ obj.get_absolute_url }}">{{ obj }}</a></li>
+                                        <li>{{ obj|linkify }}</li>
                                       {% endfor %}
                                       {% endfor %}
                                     </ul>
                                     </ul>
                                 {% elif value %}
                                 {% elif value %}

+ 3 - 7
netbox/templates/ipam/aggregate.html

@@ -29,14 +29,10 @@
             <tr>
             <tr>
               <td>Tenant</td>
               <td>Tenant</td>
               <td>
               <td>
-                {% if object.tenant %}
-                  {% if prefix.object.group %}
-                    <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                  {% endif %}
-                  <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                {% else %}
-                  <span class="text-muted">None</span>
+                {% if object.tenant.group %}
+                  {{ object.tenant.group|linkify }} /
                 {% endif %}
                 {% endif %}
+                {{ object.tenant|linkify|placeholder }}
               </td>
               </td>
             </tr>
             </tr>
             <tr>
             <tr>

+ 3 - 7
netbox/templates/ipam/asn.html

@@ -29,14 +29,10 @@
             <tr>
             <tr>
               <td>Tenant</td>
               <td>Tenant</td>
               <td>
               <td>
-                {% if object.tenant %}
-                  {% if prefix.object.group %}
-                    <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                  {% endif %}
-                  <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                {% else %}
-                  <span class="text-muted">None</span>
+                {% if object.tenant.group %}
+                  {{ object.tenant.group|linkify }} /
                 {% endif %}
                 {% endif %}
+                {{ object.tenant|linkify|placeholder }}
               </td>
               </td>
             </tr>
             </tr>
             <tr>
             <tr>

+ 4 - 11
netbox/templates/ipam/inc/panels/fhrp_groups.html

@@ -16,21 +16,14 @@
       <tbody>
       <tbody>
         {% for assignment in object.fhrp_group_assignments.all %}
         {% for assignment in object.fhrp_group_assignments.all %}
           <tr>
           <tr>
-            <td>
-              <a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.group_id }}</a>
-            </td>
-            <td>
-              {{ assignment.group.get_protocol_display }}
-            </td>
+            <td>{{ assignment.group|linkify:"group_id" }}</td>
+            <td>{{ assignment.group.get_protocol_display }}</td>
             <td>
             <td>
               {% for ipaddress in assignment.group.ip_addresses.all %}
               {% for ipaddress in assignment.group.ip_addresses.all %}
-                <a href="{{ ipaddress.get_absolute_url }}">{{ ipaddress }}</a>
-                {% if not forloop.last %}<br />{% endif %}
+                {{ ipaddress|linkify }}{% if not forloop.last %}<br />{% endif %}
               {% endfor %}
               {% endfor %}
             </td>
             </td>
-            <td>
-              {{ assignment.priority }}
-            </td>
+            <td>{{ assignment.priority }}</td>
             <td class="text-end noprint">
             <td class="text-end noprint">
               {% if perms.ipam.change_fhrpgroupassignment %}
               {% if perms.ipam.change_fhrpgroupassignment %}
                 <a href="{% url 'ipam:fhrpgroupassignment_edit' pk=assignment.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-warning btn-sm lh-1" title="Edit">
                 <a href="{% url 'ipam:fhrpgroupassignment_edit' pk=assignment.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-warning btn-sm lh-1" title="Edit">

+ 1 - 1
netbox/templates/ipam/inc/service.html

@@ -1,5 +1,5 @@
 <tr>
 <tr>
-    <td><a href="{{ service.get_absolute_url }}">{{ service.name }}</a></td>
+    <td>{{ service|linkify:"name" }}</td>
     <td>{{ service.get_protocol_display }}</td>
     <td>{{ service.get_protocol_display }}</td>
     <td>{{ service.port_list }}</td>
     <td>{{ service.port_list }}</td>
     <td>
     <td>

+ 8 - 18
netbox/templates/ipam/ipaddress.html

@@ -36,14 +36,10 @@
                   <tr>
                   <tr>
                       <th scope="row">Tenant</th>
                       <th scope="row">Tenant</th>
                       <td>
                       <td>
-                          {% if object.tenant %}
-                              {% if object.tenant.group %}
-                                  <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                              {% endif %}
-                              <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                          {% else %}
-                              <span class="text-muted">None</span>
+                          {% if object.tenant.group %}
+                              {{ object.tenant.group|linkify }} /
                           {% endif %}
                           {% endif %}
+                          {{ object.tenant|linkify|placeholder }}
                       </td>
                       </td>
                   </tr>
                   </tr>
                   <tr>
                   <tr>
@@ -73,9 +69,9 @@
                       <td>
                       <td>
                         {% if object.assigned_object %}
                         {% if object.assigned_object %}
                           {% if object.assigned_object.parent_object %}
                           {% if object.assigned_object.parent_object %}
-                            <a href="{{ object.assigned_object.parent_object.get_absolute_url }}">{{ object.assigned_object.parent_object }}</a> /
+                            {{ object.assigned_object.parent_object|linkify }} /
                           {% endif %}
                           {% endif %}
-                          <a href="{{ object.assigned_object.get_absolute_url }}">{{ object.assigned_object }}
+                          {{ object.assigned_object|linkify }}
                         {% else %}
                         {% else %}
                           <span class="text-muted">&mdash;</span>
                           <span class="text-muted">&mdash;</span>
                         {% endif %}
                         {% endif %}
@@ -85,9 +81,9 @@
                       <th scope="row">NAT (inside)</th>
                       <th scope="row">NAT (inside)</th>
                       <td>
                       <td>
                           {% if object.nat_inside %}
                           {% if object.nat_inside %}
-                              <a href="{{ object.nat_inside.get_absolute_url }}">{{ object.nat_inside }}</a>
+                              {{ object.nat_inside|linkify }}
                               {% if object.nat_inside.assigned_object %}
                               {% if object.nat_inside.assigned_object %}
-                                  (<a href="{{ object.nat_inside.assigned_object.parent_object.get_absolute_url }}">{{ object.nat_inside.assigned_object.parent_object }}</a>)
+                                  ({{ object.nat_inside.assigned_object.parent_object|linkify }})
                               {% endif %}
                               {% endif %}
                           {% else %}
                           {% else %}
                               <span class="text-muted">None</span>
                               <span class="text-muted">None</span>
@@ -96,13 +92,7 @@
                   </tr>
                   </tr>
                   <tr>
                   <tr>
                       <th scope="row">NAT (outside)</th>
                       <th scope="row">NAT (outside)</th>
-                      <td>
-                          {% if object.nat_outside %}
-                              <a href="{{ object.nat_outside.get_absolute_url }}">{{ object.nat_outside }}</a>
-                          {% else %}
-                              <span class="text-muted">None</span>
-                          {% endif %}
-                      </td>
+                      <td>{{ object.nat_outside|linkify|placeholder }}</td>
                   </tr>
                   </tr>
               </table>
               </table>
           </div>
           </div>

+ 5 - 15
netbox/templates/ipam/iprange.html

@@ -37,7 +37,7 @@
                     <th scope="row">VRF</th>
                     <th scope="row">VRF</th>
                     <td>
                     <td>
                         {% if object.vrf %}
                         {% if object.vrf %}
-                            <a href="{{ object.vrf.get_absolute_url }}">{{ object.vrf }}</a> ({{ object.vrf.rd }})
+                            {{ object.vrf|linkify }} ({{ object.vrf.rd }})
                         {% else %}
                         {% else %}
                             <span>Global</span>
                             <span>Global</span>
                         {% endif %}
                         {% endif %}
@@ -45,13 +45,7 @@
                 </tr>
                 </tr>
                 <tr>
                 <tr>
                     <th scope="row">Role</th>
                     <th scope="row">Role</th>
-                    <td>
-                        {% if object.role %}
-                            <a href="{{ object.role.get_absolute_url }}">{{ object.role }}</a>
-                        {% else %}
-                            <span class="text-muted">None</span>
-                        {% endif %}
-                    </td>
+                    <td>{{ object.role|linkify|placeholder }}</td>
                 </tr>
                 </tr>
                 <tr>
                 <tr>
                     <th scope="row">Status</th>
                     <th scope="row">Status</th>
@@ -60,14 +54,10 @@
                 <tr>
                 <tr>
                     <th scope="row">Tenant</th>
                     <th scope="row">Tenant</th>
                     <td>
                     <td>
-                        {% if object.tenant %}
-                            {% if object.tenant.group %}
-                                <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                            {% endif %}
-                            <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                        {% else %}
-                            <span class="text-muted">None</span>
+                        {% if object.tenant.group %}
+                            {{ object.tenant.group|linkify }} /
                         {% endif %}
                         {% endif %}
+                        {{ object.tenant|linkify|placeholder }}
                     </td>
                     </td>
                 </tr>
                 </tr>
                 <tr>
                 <tr>

+ 9 - 19
netbox/templates/ipam/prefix.html

@@ -26,16 +26,12 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Tenant</th>
             <th scope="row">Tenant</th>
-            <td>
-              {% if object.tenant %}
+              <td>
                 {% if object.tenant.group %}
                 {% if object.tenant.group %}
-                  <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
+                  {{ object.tenant.group|linkify }} /
                 {% endif %}
                 {% endif %}
-                <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-              {% else %}
-                <span class="text-muted">None</span>
-              {% endif %}
-            </td>
+                {{ object.tenant|linkify|placeholder }}
+              </td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Aggregate</th>
             <th scope="row">Aggregate</th>
@@ -52,9 +48,9 @@
             <td>
             <td>
               {% if object.site %}
               {% if object.site %}
                 {% if object.site.region %}
                 {% if object.site.region %}
-                  <a href="{{ object.site.region.get_absolute_url }}">{{ object.site.region }}</a> /
+                  {{ object.site.region|linkify }} /
                 {% endif %}
                 {% endif %}
-                <a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a>
+                {{ object.site|linkify }}
               {% else %}
               {% else %}
                 <span class="text-muted">None</span>
                 <span class="text-muted">None</span>
               {% endif %}
               {% endif %}
@@ -65,9 +61,9 @@
             <td>
             <td>
               {% if object.vlan %}
               {% if object.vlan %}
                 {% if object.vlan.group %}
                 {% if object.vlan.group %}
-                  <a href="{{ object.vlan.group.get_absolute_url }}">{{ object.vlan.group }}</a> /
+                  {{ object.vlan.group|linkify }} /
                 {% endif %}
                 {% endif %}
-                <a href="{% url 'ipam:vlan' pk=object.vlan.pk %}">{{ object.vlan }}</a>
+                {{ object.vlan|linkify }}
               {% else %}
               {% else %}
                 <span class="text-muted">None</span>
                 <span class="text-muted">None</span>
               {% endif %}
               {% endif %}
@@ -79,13 +75,7 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Role</th>
             <th scope="row">Role</th>
-            <td>
-              {% if object.role %}
-                <a href="{{ object.role.get_absolute_url }}">{{ object.role }}</a>
-              {% else %}
-                <span class="text-muted">None</span>
-              {% endif %}
-            </td>
+            <td>{{ object.role|linkify|placeholder }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Description</th>
             <th scope="row">Description</th>

+ 1 - 7
netbox/templates/ipam/routetarget.html

@@ -15,13 +15,7 @@
             </tr>
             </tr>
             <tr>
             <tr>
               <th  scope="row">Tenant</th>
               <th  scope="row">Tenant</th>
-              <td>
-                {% if object.tenant %}
-                  <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                {% else %}
-                  <span class="text-muted">None</span>
-                {% endif %}
-              </td>
+              <td>{{ object.tenant|linkify|placeholder }}</td>
             </tr>
             </tr>
             <tr>
             <tr>
               <th scope="row">Description</th>
               <th scope="row">Description</th>

+ 2 - 4
netbox/templates/ipam/service.html

@@ -28,9 +28,7 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Parent</th>
                         <th scope="row">Parent</th>
-                        <td>
-                            <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-                        </td>
+                        <td>{{ object.parent|linkify }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Protocol</th>
                         <th scope="row">Protocol</th>
@@ -44,7 +42,7 @@
                         <th scope="row">IP Addresses</th>
                         <th scope="row">IP Addresses</th>
                         <td>
                         <td>
                             {% for ipaddress in object.ipaddresses.all %}
                             {% for ipaddress in object.ipaddresses.all %}
-                                <a href="{{ ipaddress.get_absolute_url }}">{{ ipaddress }}</a><br />
+                                {{ ipaddress|linkify }}<br />
                             {% empty %}
                             {% empty %}
                                 <span class="text-muted">None</span>
                                 <span class="text-muted">None</span>
                             {% endfor %}
                             {% endfor %}

+ 6 - 16
netbox/templates/ipam/vlan.html

@@ -17,9 +17,9 @@
                             <td>
                             <td>
                                 {% if object.site %}
                                 {% if object.site %}
                                     {% if object.site.region %}
                                     {% if object.site.region %}
-                                        <a href="{{ object.site.region.get_absolute_url }}">{{ object.site.region }}</a> /
+                                        {{ object.site.region|linkify }} /
                                     {% endif %}
                                     {% endif %}
-                                    <a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a>
+                                    {{ object.site|linkify }}
                                 {% else %}
                                 {% else %}
                                     <span class="text-muted">None</span>
                                     <span class="text-muted">None</span>
                                 {% endif %}
                                 {% endif %}
@@ -27,13 +27,7 @@
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">Group</th>
                             <th scope="row">Group</th>
-                            <td>
-                                {% if object.group %}
-                                    <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
-                                {% endif %}
-                            </td>
+                            <td>{{ object.group|linkify|placeholder }}</td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <th scope="row">VLAN ID</th>
                             <th scope="row">VLAN ID</th>
@@ -46,14 +40,10 @@
                         <tr>
                         <tr>
                             <th scope="row">Tenant</th>
                             <th scope="row">Tenant</th>
                             <td>
                             <td>
-                                {% if object.tenant %}
-                                    {% if object.tenant.group %}
-                                        <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                                    {% endif %}
-                                    <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                                {% else %}
-                                    <span class="text-muted">None</span>
+                                {% if object.tenant.group %}
+                                    {{ object.tenant.group|linkify }} /
                                 {% endif %}
                                 {% endif %}
+                                {{ object.tenant|linkify|placeholder }}
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>

+ 2 - 7
netbox/templates/ipam/vlangroup.html

@@ -7,7 +7,7 @@
   {{ block.super }}
   {{ block.super }}
   {% if object.scope %}
   {% if object.scope %}
     {# TODO: This should link to a filtered list of VLANGroups #}
     {# TODO: This should link to a filtered list of VLANGroups #}
-    <li class="breadcrumb-item"><a href="{{ object.scope.get_absolute_url }}">{{ object.scope }}</a></li>
+    <li class="breadcrumb-item">{{ object.scope|linkify }}</li>
   {% endif %}
   {% endif %}
 {% endblock %}
 {% endblock %}
 
 
@@ -36,12 +36,7 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Scope</th>
             <th scope="row">Scope</th>
-            <td>
-            {% if object.scope %}
-              <a href="{{ object.scope.get_absolute_url }}">{{ object.scope }}</a>
-            {% else %}
-              <span class="text-muted">&mdash;</span>
-            {% endif %}
+            <td>{{ object.scope|linkify|placeholder }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Permitted VIDs</th>
             <th scope="row">Permitted VIDs</th>

+ 3 - 4
netbox/templates/ipam/vrf.html

@@ -21,11 +21,10 @@
                   <tr>
                   <tr>
                       <th scope="row">Tenant</th>
                       <th scope="row">Tenant</th>
                       <td>
                       <td>
-                          {% if object.tenant %}
-                              <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                          {% else %}
-                              <span class="text-muted">None</span>
+                          {% if object.tenant.group %}
+                              {{ object.tenant.group|linkify }} /
                           {% endif %}
                           {% endif %}
+                          {{ object.tenant|linkify|placeholder }}
                       </td>
                       </td>
                   </tr>
                   </tr>
                   <tr>
                   <tr>

+ 1 - 7
netbox/templates/tenancy/contact.html

@@ -19,13 +19,7 @@
           <table class="table table-hover attr-table">
           <table class="table table-hover attr-table">
             <tr>
             <tr>
               <td>Group</td>
               <td>Group</td>
-              <td>
-                {% if object.group %}
-                  <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
-                {% else %}
-                  <span class="text-muted">None</span>
-                {% endif %}
-              </td>
+              <td>{{ object.group|linkify|placeholder }}</td>
             </tr>
             </tr>
             <tr>
             <tr>
               <td>Name</td>
               <td>Name</td>

+ 1 - 7
netbox/templates/tenancy/contactgroup.html

@@ -29,13 +29,7 @@
             </tr>
             </tr>
             <tr>
             <tr>
               <th scope="row">Parent</th>
               <th scope="row">Parent</th>
-              <td>
-                {% if object.parent %}
-                  <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-                {% else %}
-                  <span class="text-muted">&mdash;</span>
-                {% endif %}
-              </td>
+              <td>{{ object.parent|linkify|placeholder }}</td>
             </tr>
             </tr>
             <tr>
             <tr>
               <th scope="row">Contacts</th>
               <th scope="row">Contacts</th>

+ 1 - 7
netbox/templates/tenancy/tenant.html

@@ -20,13 +20,7 @@
                 <table class="table table-hover attr-table">
                 <table class="table table-hover attr-table">
                     <tr>
                     <tr>
                         <td>Group</td>
                         <td>Group</td>
-                        <td>
-                            {% if object.group %}
-                                <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.group|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <td>Description</td>
                         <td>Description</td>

+ 1 - 7
netbox/templates/tenancy/tenantgroup.html

@@ -37,13 +37,7 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Parent</th>
             <th scope="row">Parent</th>
-            <td>
-              {% if object.parent %}
-                <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-              {% else %}
-                <span class="text-muted">&mdash;</span>
-              {% endif %}
-            </td>
+            <td>{{ object.parent|linkify|placeholder }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Tenants</th>
             <th scope="row">Tenants</th>

+ 6 - 19
netbox/templates/virtualization/cluster.html

@@ -17,37 +17,24 @@
                 </tr>
                 </tr>
                 <tr>
                 <tr>
                     <th scope="row">Type</th>
                     <th scope="row">Type</th>
-                    <td><a href="{{ object.type.get_absolute_url }}">{{ object.type }}</a></td>
+                    <td>{{ object.type|linkify }}</td>
                 </tr>
                 </tr>
                 <tr>
                 <tr>
                     <th scope="row">Group</th>
                     <th scope="row">Group</th>
-                    <td>
-                        {% if object.group %}
-                            <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
-                        {% else %}
-                            <span class="text-muted">None</span>
-                        {% endif %}
-                    </td>
+                    <td>{{ object.group|linkify }}</td>
                 </tr>
                 </tr>
                 <tr>
                 <tr>
                     <th scope="row">Tenant</th>
                     <th scope="row">Tenant</th>
                     <td>
                     <td>
-                        {% if object.tenant %}
-                            <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                        {% else %}
-                            <span class="text-muted">None</span>
+                        {% if object.tenant.group %}
+                            {{ object.tenant.group|linkify }} /
                         {% endif %}
                         {% endif %}
+                        {{ object.tenant|linkify|placeholder }}
                     </td>
                     </td>
                 </tr>
                 </tr>
                 <tr>
                 <tr>
                     <th scope="row">Site</th>
                     <th scope="row">Site</th>
-                    <td>
-                        {% if object.site %}
-                            <a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a>
-                        {% else %}
-                            <span class="text-muted">None</span>
-                        {% endif %}
-                    </td>
+                    <td>{{ object.site|linkify }}</td>
                 </tr>
                 </tr>
                 <tr>
                 <tr>
                     <th scope="row">Virtual Machines</th>
                     <th scope="row">Virtual Machines</th>

+ 7 - 23
netbox/templates/virtualization/virtualmachine.html

@@ -23,35 +23,19 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Role</th>
                         <th scope="row">Role</th>
-                        <td>
-                            {% if object.role %}
-                                <a href="{{ object.role.get_absolute_url }}">{{ object.role }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.role|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Platform</th>
                         <th scope="row">Platform</th>
-                        <td>
-                            {% if object.platform %}
-                                <a href="{{ object.platform.get_absolute_url }}">{{ object.platform }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.platform|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Tenant</th>
                         <th scope="row">Tenant</th>
                         <td>
                         <td>
-                            {% if object.tenant %}
-                                {% if object.tenant.group %}
-                                    <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
-                                {% endif %}
-                                <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
+                            {% if object.tenant.group %}
+                                {{ object.tenant.group|linkify }} /
                             {% endif %}
                             {% endif %}
+                            {{ object.tenant|linkify|placeholder }}
                         </td>
                         </td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
@@ -103,9 +87,9 @@
                         <th scope="row">Cluster</th>
                         <th scope="row">Cluster</th>
                         <td>
                         <td>
                             {% if object.cluster.group %}
                             {% if object.cluster.group %}
-                                <a href="{{ object.cluster.group.get_absolute_url }}">{{ object.cluster.group }}</a> /
+                                {{ object.cluster.group|linkify }} /
                             {% endif %}
                             {% endif %}
-                            <a href="{{ object.cluster.get_absolute_url }}">{{ object.cluster }}</a>
+                            {{ object.cluster|linkify }}
                         </td>
                         </td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>

+ 4 - 24
netbox/templates/virtualization/vminterface.html

@@ -21,9 +21,7 @@
                 <table class="table table-hover attr-table">
                 <table class="table table-hover attr-table">
                     <tr>
                     <tr>
                         <th scope="row">Virtual Machine</th>
                         <th scope="row">Virtual Machine</th>
-                        <td>
-                            <a href="{{ object.virtual_machine.get_absolute_url }}">{{ object.virtual_machine }}</a>
-                        </td>
+                        <td>{{ object.virtual_machine|linkify }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Name</th>
                         <th scope="row">Name</th>
@@ -41,33 +39,15 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Parent</th>
                         <th scope="row">Parent</th>
-                        <td>
-                            {% if object.parent %}
-                                <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.parent|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Bridge</th>
                         <th scope="row">Bridge</th>
-                        <td>
-                            {% if object.bridge %}
-                                <a href="{{ object.bridge.get_absolute_url }}">{{ object.bridge }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.bridge|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">VRF</th>
                         <th scope="row">VRF</th>
-                        <td>
-                            {% if object.vrf %}
-                                  <a href="{{ object.vrf.get_absolute_url }}">{{ object.vrf }}</a>
-                              {% else %}
-                                  <span class="text-muted">None</span>
-                              {% endif %}
-                        </td>
+                        <td>{{ object.vrf|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Description</th>
                         <th scope="row">Description</th>

+ 2 - 6
netbox/templates/wireless/inc/wirelesslink_interface.html

@@ -3,15 +3,11 @@
 <table class="table table-hover panel-body attr-table">
 <table class="table table-hover panel-body attr-table">
   <tr>
   <tr>
     <td>Device</td>
     <td>Device</td>
-    <td>
-      <a href="{{ interface.device.get_absolute_url }}">{{ interface.device }}</a>
-    </td>
+    <td>{{ interface.device|linkify }}</td>
   </tr>
   </tr>
   <tr>
   <tr>
     <td>Interface</td>
     <td>Interface</td>
-    <td>
-      <a href="{{ interface.get_absolute_url }}">{{ interface }}</a>
-    </td>
+    <td>{{ interface|linkify }}</td>
   </tr>
   </tr>
   <tr>
   <tr>
     <td>Type</td>
     <td>Type</td>

+ 2 - 14
netbox/templates/wireless/wirelesslan.html

@@ -16,13 +16,7 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <td>Group</td>
                         <td>Group</td>
-                        <td>
-                            {% if object.group %}
-                                <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.group|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">Description</th>
                         <th scope="row">Description</th>
@@ -30,13 +24,7 @@
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th scope="row">VLAN</th>
                         <th scope="row">VLAN</th>
-                        <td>
-                            {% if object.vlan %}
-                                <a href="{{ object.vlan.get_absolute_url }}">{{ object.vlan }}</a>
-                            {% else %}
-                                <span class="text-muted">None</span>
-                            {% endif %}
-                        </td>
+                        <td>{{ object.vlan|linkify|placeholder }}</td>
                     </tr>
                     </tr>
                 </table>
                 </table>
             </div>
             </div>

+ 1 - 7
netbox/templates/wireless/wirelesslangroup.html

@@ -35,13 +35,7 @@
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Parent</th>
             <th scope="row">Parent</th>
-            <td>
-              {% if object.parent %}
-                <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
-              {% else %}
-                <span class="text-muted">&mdash;</span>
-              {% endif %}
-            </td>
+            <td>{{ object.parent|linkify|placeholder }}</td>
           </tr>
           </tr>
           <tr>
           <tr>
             <th scope="row">Wireless LANs</th>
             <th scope="row">Wireless LANs</th>

+ 20 - 0
netbox/utilities/templatetags/builtins/filters.py

@@ -20,6 +20,26 @@ register = template.Library()
 # General
 # General
 #
 #
 
 
+@register.filter()
+def linkify(instance, attr=None):
+    """
+    Render a hyperlink for an object with a `get_absolute_url()` method, optionally specifying the name of an
+    attribute to use for the link text. If no attribute is given, the object's string representation will be
+    used.
+
+    If the object has no `get_absolute_url()` method, return the text without a hyperlink element.
+    """
+    if instance is None:
+        return ''
+
+    text = getattr(instance, attr) if attr is not None else str(instance)
+    try:
+        url = instance.get_absolute_url()
+        return mark_safe(f'<a href="{url}">{text}</a>')
+    except (AttributeError, TypeError):
+        return text
+
+
 @register.filter()
 @register.filter()
 def bettertitle(value):
 def bettertitle(value):
     """
     """