mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #2742: Preserve cluster assignment when editing a device
This commit is contained in:
@ -8,6 +8,11 @@ v2.5.3 (FUTURE)
|
||||
* [#2693](https://github.com/digitalocean/netbox/issues/2693) - Additional cable colors
|
||||
* [#2726](https://github.com/digitalocean/netbox/issues/2726) - Include cables in global search
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* [#2742](https://github.com/digitalocean/netbox/issues/2742) - Preserve cluster assignment when editing a device
|
||||
|
||||
|
||||
---
|
||||
|
||||
v2.5.2 (2018-12-21)
|
||||
|
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user