Re: Multi field validation with clean method

2007-08-10 Thread jeffhg58
I was finally able to figure it out as I saw on another post. Instead, of
using the RaiseValidation error I did the following:

self.errors.update(annotation=ErrorList([u'You must enter an Annotation 
Type.']))

Thanks for all your help,

Jeff

-- Original message -- 
From: rskm1 <[EMAIL PROTECTED]> 

> 
> On Aug 9, 7:34 pm, [EMAIL PROTECTED] wrote: 
> > So, if I use clean_annotationvalue to do both how would I be able to put an 
> error 
> > message on the annotation type ... 
> 
> I think you were on the right track the first time. Philosophically, 
> the Form's clean() method is where you're supposed to be doing the 
> inter-field validations, and you don't have to worry about field 
> sequence there either. 
> 
> So now your question boils down to a simple "How do I associate the 
> error message with a specific field, from the form's clean() method?" 
> 
> Normally, if you raise a ValidationError exception from 
> YourForm.clean(), the message appears in a "special" section of the 
> form._errors collection named "__all__", accessed from the template as 
> {{ form.non_field_errors }}. 
> But if you can figure out how to manually inject the message into 
> yourform._errors yourself, you could make it appear on any field you 
> want. Well, *theoretically* anyway; I haven't tried that myself, 
> since I always *want* the inter-field validation errors to appear in a 
> different spot. 
> 
> 
> > 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi field validation with clean method

2007-08-10 Thread rskm1

On Aug 9, 7:34 pm, [EMAIL PROTECTED] wrote:
> So, if I use clean_annotationvalue to do both how would I be able to put an 
> error
> message on the annotation type ...

I think you were on the right track the first time.  Philosophically,
the Form's clean() method is where you're supposed to be doing the
inter-field validations, and you don't have to worry about field
sequence there either.

So now your question boils down to a simple "How do I associate the
error message with a specific field, from the form's clean() method?"

Normally, if you raise a ValidationError exception from
YourForm.clean(), the message appears in a "special" section of the
form._errors collection named "__all__", accessed from the template as
{{ form.non_field_errors }}.
But if you can figure out how to manually inject the message into
yourform._errors yourself, you could make it appear on any field you
want.  Well, *theoretically* anyway; I haven't tried that myself,
since I always *want* the inter-field validation errors to appear in a
different spot.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi field validation with clean method

2007-08-09 Thread Collin Grady

Reverse the field order in the form, otherwise not that I'm aware of.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi field validation with clean method

2007-08-09 Thread jeffhg58
So, if I use clean_annotationvalue to do both how would I be able to put an 
error
message on the annotation type when a value is entered but no annotation type 
is entered.
Wouldn't that error message appear under the annotationvalue field

Jeff

-- Original message -- 
From: Collin Grady <[EMAIL PROTECTED]> 

> 
> The clean_foo functions are run in order. 
> 
> So in your situation, clean_annotationtype will only have access to 
> the annotationtype value, but clean_annotationvalue will be able to 
> see both, since clean_annotationtype has already been run. 
> 
> 
> > 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi field validation with clean method

2007-08-09 Thread Collin Grady

The clean_foo functions are run in order.

So in your situation, clean_annotationtype will only have access to
the annotationtype value, but clean_annotationvalue will be able to
see both, since clean_annotationtype has already been run.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---