Am Freitag, 23. November 2007 14:37 schrieb Wolfram Kriesing:
> this has two drawbacks:
>  1)  the URL is validated in the "wrong" place (in clean() instead of
> clean_url())
>  2) the error, if one occurs, is not assigned to the errors['url']
> but errors['__all__']
>
> fixing 2) would also be hackish imho

I had this problem, too.

http://code.djangoproject.com/ticket/5335

In clean() you can add the message to errors['url'] like this:
errorlist=self.errors.get(name) 
if errorlist==None: 
    errorlist=ErrorList() 
    self.errors[name]=errorlist 
errorlist.append(message) 

Since this is not nice, I wrote a small patch inclusive tests and 
documentation:
 http://code.djangoproject.com/ticket/5335

Please leave a message there if you like / don't like it.


With the patch you can add the message like this:

<pre>
class StartEnd(Form): 
     start = IntegerField() 
     end = IntegerField() 
     def clean(self): 
         start, end = self.cleaned_data.get('start'), 
self.cleaned_data.get('end') 
         if start!=None and end!=None and start>end: 
             self.errors.append('start', u'start must be smaller than end') 
         return self.cleaned_data 
</pre>

 Thomas


-- 
Thomas Güttler, http://www.tbz-pariv.de/ 
Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543

--~--~---------~--~----~------------~-------~--~----~
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