Create Django formset wihtout multiple queries
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2010-05-07T08:43:19Z
Indexed on
2010/05/07
8:48 UTC
Read the original article
Hit count: 454
I need to display multiple forms (up to 10) of a model on a page. This is the code I use for to accomplish this.
TheFormSet = formset_factory(SomeForm, extra=10)
...
formset = TheFormSet(prefix='party')
return render_to_response('template.html', {
'formset' : formset,
})
The problem is, that it seems to me that Django queries the database for each of the forms in the formset, even though the data displayed in them is the same.
Is this the way Formsets work or am I doing something wrong? Is there a way around it inside django or would I have to use JavaScript for a workaround?
© Stack Overflow or respective owner