Skip to content

Commit 3cf1d6b

Browse files
committed
Closes #7118: Render URL custom fields as hyperlinks in object tables
1 parent 2a1718b commit 3cf1d6b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Enhancements
66

7+
* [#7118](https://github.com/netbox-community/netbox/issues/7118) - Render URL custom fields as hyperlinks in object tables
78
* [#7323](https://github.com/netbox-community/netbox/issues/7323) - Add serial filter field for racks & devices
89

910
### Bug Fixes

netbox/utilities/tables.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from django_tables2.data import TableQuerysetData
1212
from django_tables2.utils import Accessor
1313

14+
from extras.choices import CustomFieldTypeChoices
1415
from extras.models import CustomField
1516
from .utils import content_type_name
1617
from .paginator import EnhancedPaginator, get_paginate_count
@@ -355,6 +356,9 @@ def __init__(self, customfield, *args, **kwargs):
355356
def render(self, value):
356357
if isinstance(value, list):
357358
return ', '.join(v for v in value)
359+
elif self.customfield.type == CustomFieldTypeChoices.TYPE_URL:
360+
# Linkify custom URLs
361+
return mark_safe(f'<a href="{value}">{value}</a>')
358362
return value or self.default
359363

360364

0 commit comments

Comments
 (0)