Answer the question
In order to leave comments, you need to log in
Python & Django / CSRF validation failed. Request denied. what's wrong?
good day everyone! I know the python well, but I'm only torturing Django for the second day. and the second day on this error.
So: the project was created according to the manual. I create a form, inside the form I write {% csrf_token %} in the default settings 'django.middleware.csrf.CsrfViewMiddleware' is enabled.
I render in a view like this:
def index(request):
cats = CategoryQuestion.objects.all().order_by("name")
return render(request, "index.html", {"cats": cats})
Answer the question
In order to leave comments, you need to log in
Mistake won! in the template the form started like this:
<form method="post" action="testing/" enctype="text/plain">
{% csrf_token %}
...
perhaps the field name is not csrfmiddlewaretoken ? or send from another domain
, see what leaves the browser in the console
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question