#27396: Docs: send POST request on base.html does not mention {{ csrf_token }}
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: nobody
Cami |
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
| worksforme
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Aymeric Augustin):
You need two things:
1. Create a CSRF token by accessing it.
2. Get this token from JavaScript.
I usually solve 1. with a trivial middleware:
{{{
class SendCsrfCookie:
"""
Send a CSRF cookie with every request.
Any page could trigger an AJAX POST request.
"""
def process_request(self, request):
csrf.get_token(request)
}}}
and 2. with the method described in the documentation.
I'm having a hard time following your comments. As far as I can tell,
you're proposing something for 2. which doesn't work at all but
accidentally triggers 1. Then something else makes 2. work in your
project. I don't think that makes sense and that's why I'm rejecting the
proposal.
--
Ticket URL: <https://code.djangoproject.com/ticket/27396#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.86ae0f9218eb8ec060524b0d741e4a31%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.