Просмотр исходного кода

Fixes #1158: Exception thrown when creating a device component with an invalid name

Jeremy Stretch 8 лет назад
Родитель
Сommit
83688fceb7
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      netbox/dcim/views.py

+ 3 - 0
netbox/dcim/views.py

@@ -105,6 +105,9 @@ class ComponentCreateView(View):
                     new_components.append(component_form.save(commit=False))
                 else:
                     for field, errors in component_form.errors.as_data().items():
+                        # Assign errors on the child form's name field to name_pattern on the parent form
+                        if field == 'name':
+                            field = 'name_pattern'
                         for e in errors:
                             form.add_error(field, u'{}: {}'.format(name, ', '.join(e)))