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

 @jkocherhans: the admin-interface works fine. I´m not exactly sure if I
 understand your question but I _do_ check form.is_valid(), resp.
 formset.is_valid() ...

 I´ve found another workaround (for my usecase):


 {{{
 if form.is_valid() and amount_formset.is_valid():
     if len([fs_form.__getitem__('DELETE').data for fs_form in
 formset.forms if fs_form.__getitem__('DELETE').data == 'on']) !=
 len(formset.forms):
         # save form, formsets, do stuff
     else:
         formset.non_form_errors = 'At least one item has to be saved.'
 }}}

 with this code example, the error won´t be thrown because it´s not allowed
 to delete _all_ items from the formset. of course, it´d be much better to
 use the formsets clean-method to perform this check (but that doesn´t
 work, unfortunately).

 please let me know if I can help with more details or testing.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10828#comment:7>
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