Wednesday, April 24, 2013

Re: Django 1.5.1 and formsets with more than 1000 initials

Hi Carsten,

When you create your FormSet with formset_factory, the max_number is set to the max of 1000 and max_num.
The fact that you set a bigger number of initials doesn't affect this number.
I'm not sure whether the FormSet could extends itself this number if the initial_data is larger than 1000. You probably could open a ticket about that.

Please note that a more flexible workaround would be:
> >>> ArticleFormSet = formset_factory(ArticleForm, max_num=len(MyInitials), extra=0)


Regards,
Xavier Ordoquy,
Linovia.


Le 24 avr. 2013 à 21:42, Carsten Fuchs <carsten.fuchs@cafu.de> a écrit :

> Hi all,
>
> using Django 1.5.1, having read <https://docs.djangoproject.com/en/1.5/topics/forms/formsets/#limiting-the-maximum-number-of-forms>, I still have trouble creating a formset with more than 1000 initial forms:
>
> Following the example at that page, what I'd like to do is, with MyInitials being a list of e.g. 1500 initial values:
>
> >>> ArticleFormSet = formset_factory(ArticleForm, extra=0)
> >>> formset = ArticleFormSet(initial=MyInitials)
>
> Now, accessing formset.forms[1000] throws an IndexError exception.
>
> I understand that this is related to the "Formset denial-of-service" issue mentioned at https://www.djangoproject.com/weblog/2013/feb/19/security/, but isn't max_num supposed to limited the number of *extra* formsets only?
>
> It is relatively easy to work-around my original problem:
>
> >>> ArticleFormSet = formset_factory(ArticleForm, max_num=30000, extra=0)
>
> but shouldn't a larger number of initials automatically extend the max_num?
>
> Best regards,
> Carsten
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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

No comments:

Post a Comment