From 19d7caf1dae9f7efc6c03ff1f0a7e24418c17661 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 20 Jul 2016 10:10:31 -0400 Subject: [PATCH] Corrects a device_type error introduced in c643e3a74f6718fd4c5a98ee0ad1da8e096582ea --- netbox/dcim/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 8b0c9cce2..c8f7eca3f 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -396,8 +396,8 @@ class DeviceForm(forms.ModelForm, BootstrapMixin): self.fields['rack'].choices = [] # Rack position + pk = self.instance.pk if self.instance.pk else None try: - pk = self.instance.pk if self.instance.pk else None if self.is_bound and self.data.get('rack') and str(self.data.get('face')): position_choices = Rack.objects.get(pk=self.data['rack'])\ .get_rack_units(face=self.data.get('face'), exclude=pk) @@ -426,7 +426,7 @@ class DeviceForm(forms.ModelForm, BootstrapMixin): self.fields['device_type'].choices = [] # Disable rack assignment if this is a child device installed in a parent device - if self.instance.device_type.is_child_device and hasattr(self.instance, 'parent_bay'): + if pk and self.instance.device_type.is_child_device and hasattr(self.instance, 'parent_bay'): self.fields['site'].disabled = True self.fields['rack'].disabled = True