Wednesday, November 9, 2011

Re: formset_factory: "extra" param doesn't work? (Django version 1.2.5)

Solved.

It's not recommended to return while in a loop
:-X

On Nov 9, 10:30 pm, bentzy <bentzy.sa...@gmail.com> wrote:
> Hi,
>
> I'm trying to run the example at documentation about formsets(https://
> docs.djangoproject.com/en/1.2/topics/forms/formsets/)
>
> It basically works, but the "extra" parameter doesn't:
>
> Following that example, I wrote:
>
> def fs(request):
>     ArticleFormSet = formset_factory(ArticleForm, extra=5 )
>     formset = ArticleFormSet()
>     print 'length:' + (str)(len(formset.forms))
>
>     for form in formset.forms:
>         print form.as_table()
>         return render_to_response('fs.html', {'formset': formset },)
>
> And I get at output:
>
> length:5
> <tr><th><label for="id_form-0-title">Title:</label></th><td><input
> type="text" name="form-0-title" id="id_form-0-title" /></td></tr>
> <tr><th><label for="id_form-0-pub_date">Pub date:</label></
> th><td><input type="text" name="form-0-pub_date" id="id_form-0-
> pub_date" /></td></tr>
> [09/Nov/2011 22:26:35] "GET /formsettest/ HTTP/1.1" 200 27
>
> ONLY one form (expected five :-( )
>
> Any help will be really appreciated!

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate