mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
* Fixes #18845: restores sort behavior for DeviceTable.name column * Remove accessor/order_by and modify DEVICE_LINK template Thanks to @alehaa for the suggestion. This also includes an additional `.select_related()` operation on `DeviceListView.queryset` to avoid extra queries. Thanks to @renatoalmeidaoliveira and @jeremystretch for pointing out the need for this.
This commit is contained in:
parent
80926cda8f
commit
78332d44c7
@ -143,9 +143,8 @@ class PlatformTable(NetBoxTable):
|
||||
class DeviceTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
|
||||
name = tables.TemplateColumn(
|
||||
verbose_name=_('Name'),
|
||||
accessor=Accessor('label'),
|
||||
template_code=DEVICE_LINK,
|
||||
linkify=True
|
||||
linkify=True,
|
||||
)
|
||||
status = columns.ChoiceFieldColumn(
|
||||
verbose_name=_('Status'),
|
||||
|
@ -35,7 +35,7 @@ WEIGHT = """
|
||||
"""
|
||||
|
||||
DEVICE_LINK = """
|
||||
{{ value|default:'<span class="badge text-bg-info">Unnamed device</span>' }}
|
||||
{{ record.label|default:'<span class="badge text-bg-info">Unnamed device</span>' }}
|
||||
"""
|
||||
|
||||
DEVICEBAY_STATUS = """
|
||||
|
@ -2034,7 +2034,7 @@ class PlatformBulkDeleteView(generic.BulkDeleteView):
|
||||
|
||||
@register_model_view(Device, 'list', path='', detail=False)
|
||||
class DeviceListView(generic.ObjectListView):
|
||||
queryset = Device.objects.all()
|
||||
queryset = Device.objects.select_related('virtual_chassis')
|
||||
filterset = filtersets.DeviceFilterSet
|
||||
filterset_form = forms.DeviceFilterForm
|
||||
table = tables.DeviceTable
|
||||
|
Loading…
Reference in New Issue
Block a user