Django

Code

Ticket #10134 (closed: fixed)

Opened 1 year ago

Last modified 11 months ago

unique_for_* broken?

Reported by: wdoekes Assigned to: Alex
Milestone: 1.1 Component: Forms
Version: SVN Keywords: unique_for_date unique_for_month unique_for_year
Cc: zerok@zerokspot.com, flosch@gmail.com Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I was looking for the unique_for_date (et al.) implementation to re-use some of it for my own purposes, but I can't seem to find it.

On these pages, I read that one can do the following: http://docs.djangoproject.com/en/dev/ref/models/fields/#unique-for-date

class Test(models.Model):
    unique_for_date = models.CharField(max_length=128, unique_for_date='date')
    date = models.DateField()

If I read it correctly, it means that when using the admin form (admin.site.register(Test)), I shouldn't be able to enter the same value for unique_for_date for the same date. But instead, the admin form does no uniqueness checking at all.

In [8616] I see that a lot of code that touches the unique_for_* is removed, but I don't see it get added in another place.

Am I missing something?

Attachments

unique_for_stuff.diff (5.7 kB) - added by Alex on 04/05/09 17:04:14.
unique_for_stuff.2.diff (5.9 kB) - added by Alex on 04/06/09 10:25:55.
unique_for_stuff.3.diff (6.3 kB) - added by Alex on 04/06/09 10:42:53.
unique_for_stuff.4.diff (10.9 kB) - added by Alex on 04/07/09 13:16:15.
Long function is longer long.

Change History

01/27/09 12:41:05 changed by kmtracey

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

This would be one of the things lost in the move from the old forms/manipulators structure to new forms. The implementation/enforcement of the parameter was removed, but not the ability to specify it, since (I believe) the intent was for the check to only be MIA for as long as model validation (#6845) was missing. Model validation was hoped to be included in 1.0, but unfortunately it is still not in trunk.

Furthermore, from what I can glean of the current implementation at http://github.com/HonzaKral/django/tree/model-validation the check for these parameters is not yet handled by model validation, either, so I'm going to leave this open rather than closing it as a dup of #6845. From what I can tell restoration of checks for parameters like this is not currently covered by #6845, nor do I see it on any of the open issues/todo type pages, so this ticket can serve as a tracker for restoring this function which seems to have slipped through the cracks somewhere. (For anyone more up-to-speed on model validation, if I'm wrong about this bit being missing, or for that matter if I'm wrong about this function intending to be re-supported via model validation, feel free to correct me.)

01/27/09 12:51:29 changed by Alex

Karen you're right about this, I'll add it to the model-validation wiki and bring it up with Honza this evening if he's on.

02/27/09 13:55:44 changed by jacob

  • stage changed from Unreviewed to Accepted.
  • milestone set to 1.1.

I think we need a similar stop-gap to unique_together for unique_for_date in 1.1.

03/11/09 18:21:16 changed by Horst Gutmann <zerok@zerokspot.com>

  • cc set to zerok@zerokspot.com.

03/17/09 20:33:33 changed by anonymous

  • cc changed from zerok@zerokspot.com to zerok@zerokspot.com, flosch@gmail.com.

04/05/09 15:05:57 changed by Alex

  • owner changed from nobody to Alex.

04/05/09 15:43:56 changed by Alex

  • component changed from Database layer (models, ORM) to Forms.

Model Validaiton isn't making it in for 1.1 so this is just going to be solved in forms.

04/05/09 17:04:14 changed by Alex

  • attachment unique_for_stuff.diff added.

04/06/09 10:25:55 changed by Alex

  • attachment unique_for_stuff.2.diff added.

04/06/09 10:42:53 changed by Alex

  • attachment unique_for_stuff.3.diff added.

04/07/09 13:16:15 changed by Alex

  • attachment unique_for_stuff.4.diff added.

Long function is longer long.

04/07/09 13:24:46 changed by Alex

That comment was supposed to say, "long function is no longer long" so as to be witty, now I just sound like an idiot :/

04/14/09 14:44:45 changed by Alex

  • has_patch set to 1.

04/18/09 11:00:34 changed by jacob

  • stage changed from Accepted to Ready for checkin.

04/30/09 08:47:40 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [10646]) Fixed #10134 -- Added unique_for_[date|day|month|year] validation to ModelForm? handling. Thanks to Alex Gaynor for the patch.

04/30/09 08:49:15 changed by russellm

(In [10647]) [1.0.X] Fixed #10134 -- Added unique_for_[date|day|month|year] validation to ModelForm? handling. Thanks to Alex Gaynor for the patch.

Merge of r10646 from trunk.

(follow-up: ↓ 14 ) 05/06/09 17:07:25 changed by shannon

does this not also resolve #8377?

(in reply to: ↑ 13 ) 05/06/09 20:29:34 changed by kmtracey

Replying to shannon:

does this not also resolve #8377?

Looks like it.


Add/Change #10134 (unique_for_* broken?)




Change Properties
Action