Django

Code

Ticket #702 (new)

Opened 3 years ago

Last modified 4 months ago

make unique_together work with ManyToMany

Reported by: hugo Assigned to: nobody
Milestone: post-1.0 Component: Validators
Version: Keywords: model-validation
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

From IRC:

  • hugo- any way to get a unique_together that works with ManyToMany? fields?
  • adrian_h I don't believe so, at the moment
  • hugo- yeah. I had it working with some simple validator, until I realized that my validator can't know wether I am creating or updating (and if updating, which one I am updating) :-)
  • hugo- I _think_ it could be done with the same check you do in manipulators_validator_unique_together in core.meta for ManyToOne?
  • hugo- or at least a very similar one
  • adrian_h If a model has unique_together = (('slug', 'sites'),), where sites is a manytomany field, would the validator check that the slug is unique per each individual site, or per the specific combination of the sites?
  • hugo- per each site
  • hugo- at least that's how you use it in reverse: you use sites.get_current() to get the curent site and then for example check get_current().get_flatfile_object() to find the flatfile for that url for that site
  • hugo- currently you can add flatfiles for the same site with the same URL and get a nice exception ...
  • adrian_h Good point
  • adrian_h This is worth a ticket

Attachments

Change History

02/26/07 10:47:17 changed by Gary Wilson <gary.wilson@gmail.com>

  • stage changed from Unreviewed to Accepted.

06/16/08 12:54:36 changed by mrts

  • component changed from Core framework to Validators.
  • milestone set to 1.0 beta.

This should be provided by model validation. As model validation is scheduled as "maybe" for 1.0, marking as 1.0 beta.

06/16/08 13:22:32 changed by anonymous

  • keywords set to model-validation.

08/09/08 09:21:25 changed by jacob

  • milestone changed from 1.0 beta to post-1.0.

Model validation is getting pushed until post-1.0, so this is, too.


Add/Change #702 (make unique_together work with ManyToMany)




Change Properties
Action