Hi Karen,

Thank you for your answer, but when i access the _errors att in a
controller methods, and
adds a new array containing a unicode string, it is not rendered like
the other error messages.
I see an output like

[u'Stuff happened']

where I put {{ form.field.errors }} in my template. I expected it to
be rendered as a normal error message (ul, li)

What am I doing wrong?

Regards, Lars Borup Jensen


On 28 Sep., 23:44, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sun, Sep 28, 2008 at 2:35 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:
>
>
>
> > Hi all,
>
> > Can I in any way add an error to a form field?
> > I have a controller method (in views.py) which needs information from
> > the session and information from the form (a CharField) to validate
> > some logic. If this fails, I want to add an error to the form field
> > saying its value is invalid, but can I do this? Ive tried accessing
> > form._errors['field_name'] = [u'Invalid'] and such, but its doesnt
> > really seem like an ideal solution..  Anyone?
>
> Why does it not seem like an ideal solution?  Does it not work?  Every time
> this question has come up (how to set an error on a field outside of raising
> ValidationError in a clean method) the answer has been "access _errors
> directly".  (Yes, if this is the recommended approach then perhaps it should
> be documented better...I think there's a ticket open on that somewhere.)
> Anyway, the broad approach you are using is what has been recommended in the
> past.  I cannot tell from what you have said if there is some detail in what
> you are doing that is making it not work or if you just don't like something
> about it.
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to