Skip to content

Fix #9750: Respect blank=True when applying uniqueness constraints#9951

Open
25punam wants to merge 2 commits intoencode:mainfrom
25punam:fix-9750-blank-field-required
Open

Fix #9750: Respect blank=True when applying uniqueness constraints#9951
25punam wants to merge 2 commits intoencode:mainfrom
25punam:fix-9750-blank-field-required

Conversation

@25punam
Copy link
Copy Markdown

@25punam 25punam commented Apr 7, 2026

refs #9750

When a model field with blank=True participates in a UniqueConstraint,
ModelSerializer may incorrectly mark the field as required when no
default value is provided.

This change updates get_uniqueness_extra_kwargs() so that fields with
blank=True are treated as optional by setting required=False and
allow_blank=True.

This helps keep serializer behavior consistent with Django model
semantics, where blank=True indicates that the field is not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant