Opened 10 years ago

Closed 9 years ago

#8377 closed (duplicate)

unique_for_date (model field option) doesn't work

Reported by: Bela Hausmann <post@…> Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: semente@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I'm not sure why, but I think it is just not implemented in the newforms-admin?

My not working code snipplet:

class BlogEntry(models.Model, generic.Article):
	slug = models.SlugField(_('slug'), unique_for_date = 'published')
	published = models.DateTimeField(_('published'), default =, editable = True)

But I don't get any validation errors in my admin interface.

Change History (7)

comment:1 Changed 10 years ago by Guilherme M. Gondim <semente@…>

Cc: semente@… added

comment:2 Changed 10 years ago by Guilherme M. Gondim <semente@…>

I have the same problem.

comment:3 Changed 10 years ago by oggie_rob

I checked on the dev list and there is some work being done with validation at the model level ("model-aware validation").

Most likely this will by fixed with #6845

comment:4 Changed 10 years ago by Gábor Farkas

i agree that the whole model-aware validation will fix this,
(and have read the thread at )

but please note, that "unique_together" seems to work correctly. so if that can work without validation-aware-models,
this one should be able to work too.. (at least imho)

so, the question is: if someone submits a patch for this, will it get included (and added to 1.0.x), or
the plan is to wait for salvation (validation-aware-models and 1.1.x)

if the answer is the waiting-for-validation-aware-models, then perhaps a note should be added to the documentation,
or a known-bugs document should be created (or is there one? i couldn't find it)

p.s: this whole "unique" situation is quite painful. i mean, we have documentation that documents an attribute
as working, while a quick " grep unique_for_date * -r" shows that the only place where the attribute is mentioned is when the field-object accepts it and stores it inside :-(

comment:5 Changed 10 years ago by anonymous

Triage Stage: UnreviewedAccepted

comment:6 Changed 10 years ago by Malcolm Tredinnick

Code that worked for the 1.0.X branch would be appropriate if somebody wanted to write up a patch.

comment:7 Changed 9 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

Didn't notice this ticket when #10134 was opened. It's now been fixed, so this one should be covered also.

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