Răsfoiți Sursa

Fixes #10040: Fix exception when ordering prefixes by flat representation

jeremystretch 3 ani în urmă
părinte
comite
279253c486
2 a modificat fișierele cu 4 adăugiri și 12 ștergeri
  1. 1 0
      docs/release-notes/version-3.3.md
  2. 3 12
      netbox/ipam/tables/ip.py

+ 1 - 0
docs/release-notes/version-3.3.md

@@ -4,6 +4,7 @@
 
 ### Bug Fixes
 
+* [#10040](https://github.com/netbox-community/netbox/issues/10040) - Fix exception when ordering prefixes by flat representation
 * [#10053](https://github.com/netbox-community/netbox/issues/10053) - Custom fields header should not be displayed when editing circuit terminations with no custom fields
 
 ---

+ 3 - 12
netbox/ipam/tables/ip.py

@@ -32,15 +32,6 @@ PREFIX_LINK = """
 <a href="{% if record.pk %}{% url 'ipam:prefix' pk=record.pk %}{% else %}{% url 'ipam:prefix_add' %}?prefix={{ record }}{% if object.vrf %}&vrf={{ object.vrf.pk }}{% endif %}{% if object.site %}&site={{ object.site.pk }}{% endif %}{% if object.tenant %}&tenant_group={{ object.tenant.group.pk }}&tenant={{ object.tenant.pk }}{% endif %}{% endif %}">{{ record.prefix }}</a>
 """
 
-PREFIXFLAT_LINK = """
-{% load helpers %}
-{% if record.pk %}
-    <a href="{% url 'ipam:prefix' pk=record.pk %}">{{ record.prefix }}</a>
-{% else %}
-    {{ record.prefix }}
-{% endif %}
-"""
-
 IPADDRESS_LINK = """
 {% if record.pk %}
     <a href="{{ record.get_absolute_url }}">{{ record.address }}</a>
@@ -229,9 +220,9 @@ class PrefixTable(TenancyColumnsMixin, NetBoxTable):
         export_raw=True,
         attrs={'td': {'class': 'text-nowrap'}}
     )
-    prefix_flat = tables.TemplateColumn(
-        template_code=PREFIXFLAT_LINK,
-        attrs={'td': {'class': 'text-nowrap'}},
+    prefix_flat = tables.Column(
+        accessor=Accessor('prefix'),
+        linkify=True,
         verbose_name='Prefix (Flat)',
     )
     depth = tables.Column(