1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #7118: Render URL custom fields as hyperlinks in object tables

This commit is contained in:
jeremystretch
2021-09-21 14:04:47 -04:00
parent 2a1718bfc8
commit 3cf1d6baf4
2 changed files with 5 additions and 0 deletions

View File

@@ -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
@@ -355,6 +356,9 @@ class CustomFieldColumn(tables.Column):
def render(self, value):
if isinstance(value, list):
return ', '.join(v for v in value)
elif self.customfield.type == CustomFieldTypeChoices.TYPE_URL:
# Linkify custom URLs
return mark_safe(f'<a href="{value}">{value}</a>')
return value or self.default