Browse Source

Fixes #1936: Trigger validation error when attempting to create a virtual chassis without specifying member positions

Jeremy Stretch 7 years ago
parent
commit
bdecf7a3e3
1 changed files with 6 additions and 5 deletions
  1. 6 5
      netbox/dcim/forms.py

+ 6 - 5
netbox/dcim/forms.py

@@ -2291,11 +2291,12 @@ class BaseVCMemberFormSet(forms.BaseModelFormSet):
         # Check for duplicate VC position values
         vc_position_list = []
         for form in self.forms:
-            vc_position = form.cleaned_data['vc_position']
-            if vc_position in vc_position_list:
-                error_msg = 'A virtual chassis member already exists in position {}.'.format(vc_position)
-                form.add_error('vc_position', error_msg)
-            vc_position_list.append(vc_position)
+            vc_position = form.cleaned_data.get('vc_position')
+            if vc_position:
+                if vc_position in vc_position_list:
+                    error_msg = 'A virtual chassis member already exists in position {}.'.format(vc_position)
+                    form.add_error('vc_position', error_msg)
+                vc_position_list.append(vc_position)
 
 
 class DeviceVCMembershipForm(forms.ModelForm):