Jelajahi Sumber

Set unit_length to empty string when not specified during cable import

Jeremy Stretch 7 tahun lalu
induk
melakukan
6140dd955a
1 mengubah file dengan 5 tambahan dan 0 penghapusan
  1. 5 0
      netbox/dcim/forms.py

+ 5 - 0
netbox/dcim/forms.py

@@ -1969,6 +1969,11 @@ class CableCSVForm(forms.ModelForm):
         self.instance.termination_b = termination_object
         self.instance.termination_b = termination_object
         return termination_object
         return termination_object
 
 
+    def clean_length_unit(self):
+        # Avoid trying to save as NULL
+        length_unit = self.cleaned_data.get('length_unit', None)
+        return length_unit if length_unit is not None else ''
+
 
 
 class CableBulkEditForm(BootstrapMixin, BulkEditForm):
 class CableBulkEditForm(BootstrapMixin, BulkEditForm):
     pk = forms.ModelMultipleChoiceField(
     pk = forms.ModelMultipleChoiceField(