From 4a9831bd23ad39329501306d5278c1b3e855cd07 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 16 Sep 2022 08:30:46 -0400 Subject: [PATCH] Fixes #10383: Fix assignment of component templates to module types via web UI --- docs/release-notes/version-3.3.md | 1 + netbox/dcim/forms/models.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index 8a6244744..2748f1edb 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -4,6 +4,7 @@ ### Bug Fixes +* [#10383](https://github.com/netbox-community/netbox/issues/10383) - Fix assignment of component templates to module types via web UI * [#10387](https://github.com/netbox-community/netbox/issues/10387) - Fix `MultiValueDictKeyError` exception when editing a device interface --- diff --git a/netbox/dcim/forms/models.py b/netbox/dcim/forms/models.py index 92545f294..5728e7f2d 100644 --- a/netbox/dcim/forms/models.py +++ b/netbox/dcim/forms/models.py @@ -1000,11 +1000,22 @@ class ComponentTemplateForm(BootstrapMixin, forms.ModelForm): class ModularComponentTemplateForm(ComponentTemplateForm): + device_type = DynamicModelChoiceField( + queryset=DeviceType.objects.all().all(), + required=False + ) module_type = DynamicModelChoiceField( queryset=ModuleType.objects.all(), required=False ) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Disable reassignment of ModuleType when editing an existing instance + if self.instance.pk: + self.fields['module_type'].disabled = True + class ConsolePortTemplateForm(ModularComponentTemplateForm): fieldsets = (