Django: CSRF token missing or incorrect

前端 未结 3 2036
广开言路
广开言路 2020-11-29 08:26

The error is at location http://127.0.0.1:8000/fileupload/form.py

I have version 1.3 of django. I have tried specifying localhost:8000 as stated in someone else\'s q

3条回答
  •  眼角桃花
    2020-11-29 09:00

    You need to pass RequestContext in render_to_response for csrf_token

    For this : (views.py)

    from django.template import RequestContext
    
    ...
    
    return render_to_response('fileupload/upload.html', {'form': c['UploadFileForm']},  RequestContext(request))
    # Added RequestContext
    

    This passes the token for csrf to the template.

提交回复
热议问题