mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 03:16:25 -06:00
Fixes #678: Server error on device import specifying an invalid device type
This commit is contained in:
parent
00508de55a
commit
0857ce0bf6
@ -852,8 +852,7 @@ class Device(CreatedUpdatedModel, CustomFieldModel):
|
|||||||
'face': "Must specify rack face when defining rack position."
|
'face': "Must specify rack face when defining rack position."
|
||||||
})
|
})
|
||||||
|
|
||||||
if self.device_type:
|
try:
|
||||||
|
|
||||||
# Child devices cannot be assigned to a rack face/unit
|
# Child devices cannot be assigned to a rack face/unit
|
||||||
if self.device_type.is_child_device and self.face is not None:
|
if self.device_type.is_child_device and self.face is not None:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
@ -880,6 +879,9 @@ class Device(CreatedUpdatedModel, CustomFieldModel):
|
|||||||
except Rack.DoesNotExist:
|
except Rack.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
except DeviceType.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
is_new = not bool(self.pk)
|
is_new = not bool(self.pk)
|
||||||
|
Loading…
Reference in New Issue
Block a user