Code

Opened 6 years ago

Closed 5 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:

Description

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 = datetime.now(), editable = True)
...

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

Attachments (0)

Change History (7)

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

  • Cc semente@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

I have the same problem.

comment:3 Changed 6 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 6 years ago by gabor

i agree that the whole model-aware validation will fix this,
(and have read the thread at http://groups.google.com/group/django-developers/browse_thread/thread/997c0c5eb36eb4f4/8825c573c111c176 )

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 6 years ago by anonymous

  • Triage Stage changed from Unreviewed to Accepted

comment:6 Changed 6 years ago by mtredinnick

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

comment:7 Changed 5 years ago by kmtracey

  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.