Creating a Django Suite Without Multiple Requests

I need to display several forms (up to 10) of the model on the page. This is the code I use to execute 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 is querying the database for each of the forms in the form set, although the data displayed in them is the same.

Is this the way Formsets work, or am I doing something wrong? Is there a way to get around it inside django or will I have to use JavaScript to work around?

+4
source share
3 answers

What happens if you use modelformset_factory instead of formset_factory ? Does it help?

+1
source

If the requests are identical, you might want to look at johnny-cache and see if it improves performance.

+1
source

Are you sure django is querying the database? Try using the Django Debug toolbar to see what kind of queries django really does.

0
source

Source: https://habr.com/ru/post/1309086/


All Articles