收到警告和错误:意外的关键字参数'queryset'



意外关键字参数'querySet'callingor调用[e:意外键字 - arg]

尝试使用form_kwargs,如堆栈溢出所示: #如何在内联表单集上使用新的Form_kwargs?

if request.method == "POST":
    ctx['formset'] = project_comparison_form_set(
        data=request.POST, files=request.FILES, queryset=ctx['projects'])  
    ctx['data1'] = request.POST.copy
    if ctx['formset'].is_valid():
        instances = ctx['formset'].save(commit=False)
        for project in instances:
            project.save()

在pylint意外关键字中同时获取警告和错误消息,构造函数'querySet'''

您不显示project_comparison_form_set定义的位置,但我认为它是modelformset_factory

在这里,您没有QuerySet参数。如果您想传递QuerySet,则可以将其传递到表单集和表单集,而不是将其传递给Modelformset_factory。

检查文档https://docs.djangoproject.com/en/4.1/topics/forms/modelforms/#changing-the-the-the-the-the-the-the-the-the-the-the-the-the--queryset一下

最新更新