From 183b9987886f6995e30a2cfefd29e9238cfb64e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20F=C3=B6lsch?= Date: Mon, 20 Sep 2021 13:21:02 +0200 Subject: [PATCH] Fix #7118: Make custom field URLs clickable in tables --- netbox/utilities/tables.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index 4d8a60114..903314923 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -11,6 +11,7 @@ from django_tables2 import RequestConfig from django_tables2.data import TableQuerysetData from django_tables2.utils import Accessor +from extras.choices import CustomFieldTypeChoices from extras.models import CustomField from .utils import content_type_name from .paginator import EnhancedPaginator, get_paginate_count @@ -344,12 +345,16 @@ class CustomFieldColumn(tables.Column): """ Display custom fields in the appropriate format. """ + def __init__(self, customfield, *args, **kwargs): self.customfield = customfield kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}') if 'verbose_name' not in kwargs: kwargs['verbose_name'] = customfield.label or customfield.name + linkify = bool(customfield.type == CustomFieldTypeChoices.TYPE_URL) + kwargs.setdefault('linkify', linkify) + super().__init__(*args, **kwargs) def render(self, value):