Opened 88 minutes ago

Last modified 82 minutes ago

#37502 assigned Cleanup/optimization

Document which constraints model formsets validate across forms — at Initial Version

Reported by: Clifford Gama Owned by: Clifford Gama
Component: Documentation Version: dev
Severity: Normal Keywords: ModelFormSet, formset
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Model formsets validate unique, unique_together, unique_for_date|month|year, and UniqueConstraints with fields and no condition across forms in the formset (#9493, #30581). This is only mentioned in passing, in ​Overriding clean() on a ModelFormSet, as the reason to call super().clean(). That passage lists only the first three. The UniqueConstraint support added in #30581 was never documented for formsets.

The docs also don't say:

  • that violation_error_message isn't used for cross-form errors; a generic "Please correct the duplicate data for …" message is shown instead;
  • that other constraints (conditional or expression-based UniqueConstraints, ExclusionConstraint) are checked only against existing rows, not across forms, so saving can raise IntegrityError.

​PR

Thanks Tim Schilling for reviving this work.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top