#8435: Using multiple formsets within a single template
----------------------+-----------------------------------------------------
 Reporter:  takkun    |       Owner:  nobody     
   Status:  new       |   Milestone:  1.0 maybe  
Component:  Forms     |     Version:  1.0-alpha-2
 Keywords:  formsets  |       Stage:  Unreviewed 
Has_patch:  0         |  
----------------------+-----------------------------------------------------
 As of this moment one is able to utilize multiple formsets within a single
 view, as long as one does not use the same variable name for the fields in
 the respective forms. But this breaks down on the template level,
 specifically the management_form portion of formsets. The variables form-
 TOTAL_FORMS and form-INITIAL_FORMS are shared for all formsets when you
 include each formset's management_form in the template: {{
 formset.management_form }}.

 The problem isn't immediately apparent since the template will render
 correctly due to the fact that you call the management_form for each
 formset, thus in turn over-writing the variables form-TOTAL_FORMS and
 form-INITIAL_FORMS each time you do. The trouble begins when you start
 processing the request.POST data.

 Let's say you have 2 formsets displayed in a template, the first one you
 configure with 4 fields and the second with 2 fields. When you then
 process the POST data in the view by calling "for form in formset1.forms"
 it will only iterate 2 times oppose to the 4 times one would initially
 expect, all due to the fact that formset2's management_form has now over-
 written the form-TOTAL_FORMS variable; thus you lose whatever data was
 submitted in the remaining 2 fields in formset1.

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