From 6ca82a0901543374590887226dc029ad6fcbdfe5 Mon Sep 17 00:00:00 2001 From: Martin Hauser Date: Thu, 22 Jan 2026 22:34:47 +0100 Subject: [PATCH] fix(dcim): Avoid clearing scope on clone ScopedForm._set_scoped_values() cleared initial['scope'] whenever the scope_type differed from the instance value. During cloning (unsaved instance), this runs on the initial GET and wipes the pre-filled scope, forcing the user to re-select it. Only clear the scope when editing an existing object (instance.pk set) and the scope type has actually changed. Fixes #21202 --- netbox/dcim/forms/mixins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/dcim/forms/mixins.py b/netbox/dcim/forms/mixins.py index af618eb83..30314274d 100644 --- a/netbox/dcim/forms/mixins.py +++ b/netbox/dcim/forms/mixins.py @@ -75,7 +75,7 @@ class ScopedForm(forms.Form): except ObjectDoesNotExist: pass - if self.instance and scope_type_id != self.instance.scope_type_id: + if self.instance and self.instance.pk and scope_type_id != self.instance.scope_type_id: self.initial['scope'] = None else: