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

Fixes #21213: Make Tag weight field required in forms (#21218)

The weight field was explicitly declared with required=False in TagForm
and TagImportForm, allowing empty submissions that would crash with a
database IntegrityError since the column is NOT NULL.

By removing the explicit field override, Django now auto-generates the
form field from the model, which has default=1000 and is required.

Co-authored-by: adionit7 <adionit7@users.noreply.github.com>
Aditya Sharma 3 недель назад
Родитель
Сommit
3cc1f30287
2 измененных файлов с 0 добавлено и 8 удалено
  1. 0 4
      netbox/extras/forms/bulk_import.py
  2. 0 4
      netbox/extras/forms/model_forms.py

+ 0 - 4
netbox/extras/forms/bulk_import.py

@@ -271,10 +271,6 @@ class EventRuleImportForm(OwnerCSVMixin, NetBoxModelImportForm):
 
 class TagImportForm(OwnerCSVMixin, CSVModelForm):
     slug = SlugField()
-    weight = forms.IntegerField(
-        label=_('Weight'),
-        required=False
-    )
     object_types = CSVMultipleContentTypeField(
         label=_('Object types'),
         queryset=ObjectType.objects.with_feature('tags'),

+ 0 - 4
netbox/extras/forms/model_forms.py

@@ -571,10 +571,6 @@ class TagForm(ChangelogMessageMixin, OwnerMixin, forms.ModelForm):
         queryset=ObjectType.objects.with_feature('tags'),
         required=False
     )
-    weight = forms.IntegerField(
-        label=_('Weight'),
-        required=False
-    )
 
     fieldsets = (
         FieldSet('name', 'slug', 'color', 'weight', 'description', 'object_types', name=_('Tag')),