#5335: newforms: Custom validation.
------------------------------------------------+---------------------------
Reporter: Thomas Güttler <[EMAIL PROTECTED]> | Owner:
nobody
Status: reopened | Component:
django.newforms
Version: SVN | Resolution:
Keywords: | Stage:
Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
------------------------------------------------+---------------------------
Changes (by Thomas Güttler <[EMAIL PROTECTED]>):
* status: closed => reopened
* resolution: invalid =>
Comment:
Thank you brosner, for looking at this patch. But I can't use
clean_FIELD():
if clean_FIELD() requires to look at FIELD2, the dict self.cleaned_data
does not contain
FIELD2. If you need the cleaned values of two fields for validation, you
can not use clean_FIELD().
Nevertheless I want the error message to be near the field FIELD.
Here is how I use the patch:
{{{
def clean(self):
parent=self.cleaned_data.get("parent")
name=self.cleaned_data.get("name")
if ....:
# Needs Django Patch #5335
self.errors.append("name", u'...')
return self.cleaned_data
}}}
Of course I could do this without the patch, too:
{{{
errorlist=self.errors.get(name)
if errorlist==None:
errorlist=ErrorList()
self.errors[name]=errorlist
errorlist.append(message)
}}}
But that's too much code, I don't want to repeat. Maybe the documentation
should
be updated, too.
--
Ticket URL: <http://code.djangoproject.com/ticket/5335#comment:2>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---