From ca12f39c1ab46f0ee400bd82b620b4cda4b27fa2 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 8 Apr 2025 14:53:25 -0400 Subject: [PATCH] Return null config params for tables with no model --- netbox/netbox/tables/tables.py | 4 +++- netbox/templates/htmx/table.html | 4 +++- netbox/templates/inc/table_controls_htmx.html | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/netbox/netbox/tables/tables.py b/netbox/netbox/tables/tables.py index 040a3a60e..37540a92b 100644 --- a/netbox/netbox/tables/tables.py +++ b/netbox/netbox/tables/tables.py @@ -193,8 +193,10 @@ class BaseTable(tables.Table): @property def config_params(self): + if not (model := getattr(self.Meta, 'model', None)): + return None return urlencode({ - 'object_type': ObjectType.objects.get_for_model(self.Meta.model).pk, + 'object_type': ObjectType.objects.get_for_model(model).pk, 'table': self.name, **self.configuration, }) diff --git a/netbox/templates/htmx/table.html b/netbox/templates/htmx/table.html index 376764cef..49788ffa9 100644 --- a/netbox/templates/htmx/table.html +++ b/netbox/templates/htmx/table.html @@ -20,7 +20,9 @@
{{ table.rows|length }}
{# Include the updated "save" link for the table configuration #} - Save + {% if table.config_params %} + Save + {% endif %} {# Update the bulk action buttons with new query parameters #} {% if actions %} diff --git a/netbox/templates/inc/table_controls_htmx.html b/netbox/templates/inc/table_controls_htmx.html index 29a2c47c6..0bcd25e76 100644 --- a/netbox/templates/inc/table_controls_htmx.html +++ b/netbox/templates/inc/table_controls_htmx.html @@ -34,7 +34,9 @@ Toggle Dropdown