创建Django formset而无需多个查询

Mar*_*tin 5 python django django-forms

我需要在页面上显示模型的多个表单(最多10个).这是我用来完成此任务的代码.

TheFormSet = formset_factory(SomeForm, extra=10)
...
formset = TheFormSet(prefix='party')

return render_to_response('template.html', {
        'formset' : formset,
})
Run Code Online (Sandbox Code Playgroud)

问题是,在我看来,Django在数据库中查询formset中的每个表单,即使它们中显示的数据是相同的.

这是Formsets的工作方式还是我做错了什么?在django中是否有解决方法或者我是否必须使用JavaScript进行解决?

Dan*_*man 1

modelformset_factory如果您使用而不是会发生什么formset_factory?这有帮助吗?