On Mar 28, 2009, at 12:26 PM, Daniel Roseman wrote:

>
> On Mar 28, 4:14 pm, Jack Orenstein <j...@geophile.com> wrote:
>> My application needs to validate data from a from beyond the
>> validation of Fields done by django. So in my form handler, I check
>> Form.is_valid, and if that returns true, then I do my own validation.
>> In case of errors, I attach an error message to the field, e.g.
>>
>>      self.form.fields['foobar'].errors = 'some error message'
>>
>> And then I redisplay the form. But the error message doesn't show up,
>> even though the template includes
>>
>>      {{ form.foobar.errors }}
>>
>> And through logging I have confirmed that the errors attribute of the
>> field has been set, right before the render_to_response call
>> containing the form. I'm guessing that this has something to do with
>> the fact that the form already passed the is_valid check.
>>
>> How can I force the form to become "invalid" again, once my own
>> validation detects errors?
>>
>> Jack Orenstein
>
> Try self.form._errors['foobar'] instead.

That works, thank you.

Why does it work?

Jack

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to