Error while accessing request.session['key'] inside forms. [using CheckboxSelectMultiple]

前端 未结 1 1470
长情又很酷
长情又很酷 2020-12-22 10:07

I have two forms named GoodAtForm and PaidForForm. What these do is as follows...

  1. GoodAtForm Takes an input from a l

相关标签:
1条回答
  • 2020-12-22 10:46

    Usually the first "positional" argument passed to a Django form is the request data, you've defined request as the first argument to your form class but are passing request.POST in your view

    You either need to pass request as the first argument every time that you instantiate your form

    form = GoodForm(request, request.POST)
    

    or change request to be a keyword argument

    class GoodAtForm(forms.Form):
        def __init__(self, *args, request=None, **kwargs):
            super().__init__(*args, **kwargs)
            ...
    
    form = GoodForm(request.POST, request=request)
    
    0 讨论(0)
提交回复
热议问题