From cea0b2de33fbe726571dc95245b9fac022646d22 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 17 Mar 2016 18:05:01 -0400 Subject: [PATCH] Fixed bug when assigning Device to no rack race --- netbox/dcim/forms.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 5a3c0f9a1..97ebe025f 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -307,10 +307,13 @@ class DeviceForm(forms.ModelForm, BootstrapMixin): self.fields['rack'].choices = [] # Rack position + face = self.data.get('face') + if face == '': + face = None try: - if self.is_bound and self.data.get('rack') and self.data.get('face') is not None: - position_choices = Rack.objects.get(pk=self.data['rack']).get_rack_units(face=self.data.get('face')) - elif self.initial.get('rack') and self.initial.get('face') is not None: + if self.is_bound and self.data.get('rack') and face is not None: + position_choices = Rack.objects.get(pk=self.data['rack']).get_rack_units(face=face) + elif self.initial.get('rack') and face is not None: position_choices = Rack.objects.get(pk=self.initial['rack']).get_rack_units(face=self.initial.get('face')) else: position_choices = []