On Sun, 2009-03-15 at 04:25 -0700, Kegan wrote:
> I am dealing with formset, and finding the lack of documentation in
> understanding it. Hope anyone experienced with formset could help.

At some point just opening up the relevant source file is always a good
solution. It's only Python code and not particularly difficult to
understand.

Or experiment. Create a formset and vary the parameters you are
interested in and see how it affects the displayed form.

> 
> What is the reason to have a "max_num" and "extra" argument when
> instantiating a form set (using formset_factory)? Can't you just use
> "max_num" to determine the number of forms in the form set?

The max_num parameter is the number of forms that are populated with
initial data to display. It means you can pass in, say,  a queryset (for
modelformsets) without having to make sure it only contains the right
number of records.

If there are more records in the queryset than max_num, the first
records are used and the latter ones discarded.

The "extra" parameter is the number of blank forms to display (extra
forms with no data populated).
> 
> Also, management_form render "form-TOTAL_FORM", and 'form-
> INITIAL_FORMS', ... how is this correspond to "max_num" or "extra", or
> they don't?

The total form count is the total number of forms and the initial form
count is the number of "initial" forms -- forms populated with initial
data -- in the form set.

Those values' upper-bounds can be computed from max_num and extra (since
initial forms won't be greater than max_num) and, thus, total forms
won't be greater than max_num + extra. But they are only upper bounds.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to