|
|
@@ -1213,11 +1213,13 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|
|
|
|
|
# Initialize helper selectors
|
|
|
instance = kwargs.get('instance')
|
|
|
+ if 'initial' not in kwargs:
|
|
|
+ kwargs['initial'] = {}
|
|
|
# Using hasattr() instead of "is not None" to avoid RelatedObjectDoesNotExist on required field
|
|
|
if instance and hasattr(instance, 'device_type'):
|
|
|
- initial = kwargs.get('initial', {}).copy()
|
|
|
- initial['manufacturer'] = instance.device_type.manufacturer
|
|
|
- kwargs['initial'] = initial
|
|
|
+ kwargs['initial']['manufacturer'] = instance.device_type.manufacturer
|
|
|
+ if instance and instance.cluster is not None:
|
|
|
+ kwargs['initial']['cluster_group'] = instance.cluster.group
|
|
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|