mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-21 11:37:21 -06:00
Fixes #19466. Remove unnecessary saving
This commit is contained in:
parent
fc98294812
commit
049f048072
@ -54,6 +54,9 @@ def clear_primary_ip(instance, **kwargs):
|
|||||||
"""
|
"""
|
||||||
When an IPAddress is deleted, trigger save() on any Devices/VirtualMachines for which it was a primary IP.
|
When an IPAddress is deleted, trigger save() on any Devices/VirtualMachines for which it was a primary IP.
|
||||||
"""
|
"""
|
||||||
|
origin = kwargs.get('origin')
|
||||||
|
if isinstance(origin, (Device, VirtualMachine)) and origin.primary_ip4 == instance:
|
||||||
|
return
|
||||||
field_name = f'primary_ip{instance.family}'
|
field_name = f'primary_ip{instance.family}'
|
||||||
if device := Device.objects.filter(**{field_name: instance}).first():
|
if device := Device.objects.filter(**{field_name: instance}).first():
|
||||||
device.snapshot()
|
device.snapshot()
|
||||||
|
Loading…
Reference in New Issue
Block a user