#10828: deleting all forms within a formset is not possible
-------------------------------+--------------------------------------------
          Reporter:  patrickk  |         Owner:  nobody
            Status:  new       |     Milestone:  1.2   
         Component:  Forms     |       Version:  SVN   
        Resolution:            |      Keywords:        
             Stage:  Accepted  |     Has_patch:  1     
        Needs_docs:  1         |   Needs_tests:  0     
Needs_better_patch:  0         |  
-------------------------------+--------------------------------------------
Comment (by anentropic):

 I think I've encountered this bug...

 I have code in a view like this:

 {{{
         img_formset = ImageFormset(instance=gallery, data=request.POST,
 prefix='gallery')
         if img_formset.is_valid():
             images = img_formset.save(commit=False)
             for image in images:
                 image.gallery = gallery
                 image.save()

             del_count = len(img_formset.deleted_forms)
 }}}

 It works ok if I have several rows in the formset and go to delete one of
 them, but if there's only one and I try to delete it I get:[[BR]]
 ''''GalleryImageForm' object has no attribute 'cleaned_data''''

 Which is caused by my last line, trying to get
 len(img_formset.deleted_forms) - the error is raised by this line of
 formsets.py _get_deleted_forms():[[BR]]
 '''if form.cleaned_data[DELETION_FIELD_NAME]:'''

 According to the docs 'cleaned_data' should always be available if the
 form is_valid(), no?  This is fairly basic form stuff not working. Someone
 above said #5524 needs to be fixed for this, but that's been sitting there
 for 2 years with no progress apparently.

 Also, um, anyone know how to actually download eg copelco's diff file?  Or
 do I have to look at the html formatted diff page linked above and make
 the changes manually?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10828#comment:17>
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 django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.


Reply via email to