From 9f3bddfbb16e64e02301a88ac44b853de967f9a3 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 27 Jul 2026 12:31:26 +0200 Subject: [PATCH] fix: handle NetBox form clean return value Read installation destinations from self.cleaned_data because NetBox 4.6.5 form mixins return None while cleaning newly created objects. --- CHANGELOG.md | 1 + README.md | 2 +- netbox_slm/__init__.py | 2 +- netbox_slm/forms/software_product_installation.py | 10 +++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c34f7e..1ed91e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed * Make the required single platform destination explicit when creating an installation +* Fix installation form submission on NetBox v4.6.5 when form mixins return no cleaned-data value ### Added diff --git a/README.md b/README.md index 26b7157..2481d4b 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Die installierte Version kann anschließend geprüft werden: /opt/netbox/venv/bin/pip show netbox-slm ``` -Für diese Variante muss dort mindestens Version `1.11.1` stehen. +Für diese Variante muss dort mindestens Version `1.11.2` stehen. ### 3. Plugin in NetBox aktivieren diff --git a/netbox_slm/__init__.py b/netbox_slm/__init__.py index dae1884..b498ee9 100644 --- a/netbox_slm/__init__.py +++ b/netbox_slm/__init__.py @@ -17,7 +17,7 @@ limitations under the License. from netbox.plugins import PluginConfig from django.utils.translation import gettext_lazy as _ -__version__ = "1.11.1" +__version__ = "1.11.2" class SLMConfig(PluginConfig): diff --git a/netbox_slm/forms/software_product_installation.py b/netbox_slm/forms/software_product_installation.py index ebed762..5cf8ad3 100644 --- a/netbox_slm/forms/software_product_installation.py +++ b/netbox_slm/forms/software_product_installation.py @@ -75,15 +75,15 @@ class SoftwareProductInstallationForm(NetBoxModelForm): return version def clean(self): - cleaned_data = super().clean() + super().clean() destinations = [ - cleaned_data.get("device"), - cleaned_data.get("virtualmachine"), - cleaned_data.get("cluster"), + self.cleaned_data.get("device"), + self.cleaned_data.get("virtualmachine"), + self.cleaned_data.get("cluster"), ] if sum(destination is not None for destination in destinations) != 1: raise ValidationError(_("Select exactly one platform destination: device, virtual machine, or cluster.")) - return cleaned_data + return self.cleaned_data class SoftwareProductInstallationFilterForm(NetBoxModelFilterSetForm):