Re: Newforms / Validation / Uniqueness

2007-06-01 Thread Nebojša Đorđević
On 31.05.2007., at 04:30, Malcolm Tredinnick wrote: > On Wed, 2007-05-30 at 08:31 -0700, ringemup wrote: > [...] >>> So a "uniqueness" constraint on your model is not something that the >>> form framework is really in a position to check. Instead, what >>> should >>> happen is you construct

Re: Newforms / Validation / Uniqueness

2007-05-31 Thread ringemup
> Since full model-aware validation doesn't exist yet, example code would > be premature. :-) Ah, sorry, I thought you were saying that models have an existing validate() method that could be called on an object constructed by a form. On May 30, 3:18 pm, "Alfonso Ali" <[EMAIL PROTECTED]>

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Malcolm Tredinnick
On Wed, 2007-05-30 at 08:31 -0700, ringemup wrote: [...] > > So a "uniqueness" constraint on your model is not something that the > > form framework is really in a position to check. Instead, what should > > happen is you construct the model object and then call > > object.validate(), which

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Alfonso Ali
My solution is to use the base class parameter of form_for_[model|instance] function, for example: class SomeTest(models.Model): name = models.CharField(maxlength=50) user = models.ForeignKey(User) class Meta: unique_together = (('user', 'name'),) class

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Horst Gutmann
ringemup wrote: > > Do you then have to figure out which errors apply to which Form > fields, and sort them out and assign them? I haven't seen any sample > code doing anything of this sort, so I'd be very interested to see how > it works. > I was recently in the same situation and did

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread ringemup
> The short answer to your problem is probably to not use form_for_model() > if you want this sort of support. Instead write your own Form sub-class > and write a clean() method for it. The form_for_model() function is just > an aid after all; it shouldn't be the only thing you ever consider >

Re: Newforms / Validation / Uniqueness

2007-05-30 Thread Thomas Guettler
Am Dienstag, 29. Mai 2007 21:19 schrieb ringemup: > Hello -- > > I'm using a basic form_for_model() form object for a model that has a > unique=True constraint on a field other than the primary key. > > When validating submitted data, is there a reason the form check that > that constraint hasn't

Re: Newforms / Validation / Uniqueness

2007-05-29 Thread Malcolm Tredinnick
On Tue, 2007-05-29 at 12:19 -0700, ringemup wrote: > Hello -- > > I'm using a basic form_for_model() form object for a model that has a > unique=True constraint on a field other than the primary key. > > When validating submitted data, is there a reason the form check that > that constraint

Newforms / Validation / Uniqueness

2007-05-29 Thread ringemup
Hello -- I'm using a basic form_for_model() form object for a model that has a unique=True constraint on a field other than the primary key. When validating submitted data, is there a reason the form check that that constraint hasn't been violated and throw a validation error? I'd like to be