#12295: A formset with no forms does not call self.clean() when self.is_valid() 
is
called.
-------------------------+--------------------------------------------------
 Reporter:  tomevans222  |       Owner:  nobody    
   Status:  new          |   Milestone:            
Component:  Forms        |     Version:  1.1       
 Keywords:  formset      |       Stage:  Unreviewed
Has_patch:  0            |  
-------------------------+--------------------------------------------------
 Test case:

 {{{
 from django import forms
 from django.forms.formsets import BaseFormSet, formset_factory

 class EmptyFsetWontValidate(BaseFormSet):
   def clean(self):
     raise forms.ValidationError, "Clean method called"

 class SimpleForm(forms.Form):
   name = forms.CharField()

 EmptyFsetWontValidateFormset = formset_factory(SimpleForm, extra=0,
 formset=EmptyFsetWontValidate)
 formset = EmptyFsetWontValidateFormset({'form-INITIAL_FORMS':'0', 'form-
 TOTAL_FORMS':'0'})
 formset2 = EmptyFsetWontValidateFormset({'form-INITIAL_FORMS':'0', 'form-
 TOTAL_FORMS':'1', 'form-0-name':'bah' })

 # will return True
 formset.is_valid()
 # will return False
 formset2.is_valid()
 # But examine formset.errors...
 formset.errors
 # and now is_valid() will return False
 formset.is_valid()
 }}}

 Test case is pretty straightforward. Trivial patch is attached.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12295>
Django <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.


Reply via email to