Задать вопрос

Тел: +7 965 3737 888

455

Просмотров

0

Ответов

Dynamically alter the attributes of a formset

Allow you to specify a "General case formset/modelformset" and then alter the attributes of that formset, specificly: extra, can_order, can_delete and max_num.

So you specify:

formset = AuthorFormSet(queryset=Author.objects.filter(name__startswith='O')) and then you want to dynamically add multiple fields with javascript and save the new ones. By default a formset only has 1 extra field. With this you can return a new formset (using the same queryset, forms, formset base class, etc) but with different attributes. So you could then add 10 extra fields if the user added 10 new forms.

Вопрос полезен? Да0/Нет0
file_3924.py(691.0б)
None