#14951 closed (fixed)
Unique_for_[date|month|year] fails when the DateField is empty
| Reported by: | Ben Spaulding | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.3-alpha |
| Severity: | Keywords: | blocker, regression | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Using the following fields on a model:
slug = models.SlugField(unique_for_date='pubdate') pubdate = models.DateTimeField(blank=True, null=True)
Leads to the following error when pubdate is left empty and one tries to save the model instance:
Django Version: 1.3 alpha 1 Exception Type: AttributeError Exception Value: 'NoneType' object has no attribute 'day' Exception Location: /Users/…/django/db/models/base.py in _perform_date_checks, line 744
(It appears that this issue was addressed years ago, but regressions happen. See #2155.)
Attachments (1)
Change History (8)
comment:1 by , 15 years ago
| milestone: | → 1.3 |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
by , 15 years ago
| Attachment: | 14951.diff added |
|---|
comment:2 by , 15 years ago
| Has patch: | set |
|---|
comment:3 by , 15 years ago
| Keywords: | blocker regression added |
|---|
comment:4 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:5 by , 15 years ago
I forgot to thank benspaulding in the commit message for bringing this regression to our attention.
comment:6 by , 15 years ago
(In [15182]) [1.2.X] Fixed #14951 -- Made the unique_for_{date,month,year} model field constraints to not fail when the related DateField is empty.
Existing modelforms tests were extended to cover this case and an equivalent set of tests was added for the model functionality.
Backport of [15167] from trunk.
Regressions *shouldn't* happen -- that's what the test suite is for :-)
Since this is a regression, its a 1.3 blocker.