I am a beginner and searched a lot about it but do not got any thing please explain why this error is coming.
I have used this code from here:
JavaScript post request like a form submit
Error is coming from the following code in my html template in under script tag:
This code is from Davidson Lima comment:
post("{% url 'savep' %}", {name: user_name, pass: user_pass, csrfmiddlewaretoken: $("#csrf_token").val()});
Here is the code of views.py
def save_login(request):
x = request.POST['user']
y = request.POST['pass']
member = credentials(user_name=x, user_pass=y)
member.save()
Error:
Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF token from POST has incorrect length.