Compare commits

..

1 Commits

Author SHA1 Message Date
Martin Hauser
6ca82a0901 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
2026-01-22 22:34:47 +01:00

View File

@@ -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: