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>
This commit is contained in:
Aditya Sharma
2026-01-20 22:20:31 +05:30
committed by GitHub
parent 040a2ae9a9
commit 3cc1f30287
2 changed files with 0 additions and 8 deletions

View File

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

View File

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