[Django]-Django 1.2 – Pb with a form in a template (WSGIRequest)

6πŸ‘

βœ…

If I remember correctly, the error you are getting happens because you got the signature of form’s initializer wrong: the first argument to it is β€œdata”, which in your case resides in request.POST (and not the request itself), if you are arriving on a POST that is.

Commonly a view with a form will look something like this:

def my_view(request, ...):
    if request.method == 'POST': # The form has been submitted
        form = MyForm(request.POST)
        if form.is_valid():
            # do whatever you want here, save the form, etc
    else:
        form = MyForm()
    return render_to_response('myform.html', ... )
πŸ‘€shylent

Leave a comment