I am getting a 'CSRF token missing or incorrect' error, but I have already added the {% csrf_token%}
tag in the web form. Any idea why I still face this error?
def index(request):
if request.method == 'POST':
form = RequestForm(request.POST)
if form.is_valid():
form.save()
return render(request, 'index.html')
else:
form = RequestForm()
return render(request, 'index.html', {'form': form})`
I cannot post the template, but I use the token as shown in line below
<form id="reqForm" action="" method="POST" enctype="text/plain">{% csrf_token %}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…