I'm getting the "csrf token missing or incorrect" error in my django app. I have the csrf token in my template:
<form action="/hello/compare_lname" method="post" enctype="multipart/form-data>{% csrf_token %}
I use request in render() in my view.py:
render(request, 'delta.html',{'delta_dict': delta_dict})
I put a print statement in _compare_salted_tokens
in middleware.csrf
print(request_csrf_token, csrf_token).
request_csrf_token
is changing. csrf_token
doesn't change, even if I restart the server. csrf_token
comes from:
csrf_token = request.META.get('CSRF_COOKIE')
Do I need to reset request.META.get('CSRF_COOKIE')
somehow?
If your form tag is pasted directly from your template then you're missing an end quote on the enctype
attribute.