mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Fixed bug when assigning Device to no rack race
This commit is contained in:
parent
26b2b23e84
commit
cea0b2de33
@ -307,10 +307,13 @@ class DeviceForm(forms.ModelForm, BootstrapMixin):
|
|||||||
self.fields['rack'].choices = []
|
self.fields['rack'].choices = []
|
||||||
|
|
||||||
# Rack position
|
# Rack position
|
||||||
|
face = self.data.get('face')
|
||||||
|
if face == '':
|
||||||
|
face = None
|
||||||
try:
|
try:
|
||||||
if self.is_bound and self.data.get('rack') and self.data.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=self.data.get('face'))
|
position_choices = Rack.objects.get(pk=self.data['rack']).get_rack_units(face=face)
|
||||||
elif self.initial.get('rack') and self.initial.get('face') is not None:
|
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'))
|
position_choices = Rack.objects.get(pk=self.initial['rack']).get_rack_units(face=self.initial.get('face'))
|
||||||
else:
|
else:
|
||||||
position_choices = []
|
position_choices = []
|
||||||
|
Loading…
Reference in New Issue
Block a user