django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

fix(blank/unique): add `default` handling for `blank=True` field

Open sshishov opened this issue 5 months ago • 3 comments

Description

This MR should fix the issue with blank=True field in UniqueTogether constraint. It should not become required all of a sudden.

Fixes https://github.com/encode/django-rest-framework/issues/9750

sshishov avatar Aug 02 '25 12:08 sshishov

I have added tests similar to the tests added in https://github.com/encode/django-rest-framework/pull/9531

sshishov avatar Aug 02 '25 12:08 sshishov

Hi @sshishov @auvipy @deepakangadi, I'm excited to contribute to DRF as my first contribution! I noticed this PR (#9751) addresses a critical issue (#9750) with blank=True fields in UniqueConstraints, which aligns with my experience in Django/DRF serializers and API optimization.

I can help unblock this by:

  • Fixing the typo in test_blank_uqnique_constraint_fields_are_not_required (uqnique → unique).
  • Splitting assertions in the test for clarity, as suggested by @deepakangadi.
  • Adding char length limit (e.g., max_length=255) to the constraint.
  • Resolving conflicts by rebasing on main.
  • Checking for overlap with PR #9725, as mentioned by @auvipy.

If this sounds good, I can start working on these changes. Should I update this branch (if permitted) or create a new PR? Thanks for your guidance!

mahdighadiriii avatar Sep 27 '25 14:09 mahdighadiriii

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 18 '25 07:10 stale[bot]