Create Django formset wihtout multiple queries
- by Martin
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?