unique_for_date/month/year is very brittle and over time will likely be a source for unexpected behaviour.
unique_for_date/month/year prevents entry of two records with the same value on the same date or month or year.
However, this feature is unfortunately brittle:
Model.validate_unique()and so will not occur if Model.save() is called without first calling
Model.validate_unique()is called when using a ModelForm that does not include a field involved in the check.
Most of these problems can be mitigated by moving the validation to
If we spot this issue in your GitHub pull request we give this advice:
Django Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code
brittle-unique-for in your pyproject.toml file.