On Fri, Jul 24, 2009 at 10:46 AM, Benjamin  Wohlwend<[email protected]> wrote:
>
> On Jul 24, 10:37 am, Benjamin  Wohlwend <[email protected]> wrote:
>
>>
>> if all(f.is_valid() for f in (form1, form2, form3)):
>>     # ok, save
>>
>
> Oops, forgot to mention that I had to implement my own version of all
> (), which doesn't short cut:
>
> def really_all(iter):
>    all_true = True
>    for val in iter:
>        if not val:
>            all_true = False
>    return all_true


There is a function in Django proper which does exactly that:
django.forms.formsets.all_valid

Since is_valid works the same for forms and formsets you can use this
for plain forms too.


Matthias

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to