#29785: Using {{ csrf_token }} throws exception (AttributeError: 'dict' object
has
no attribute 'META') if no render context
-----------------------------------+--------------------------------------
Reporter: jeffrey k eliasen | Owner: nobody
Type: Bug | Status: new
Component: CSRF | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+--------------------------------------
Description changed by jeffrey k eliasen:
Old description:
> Using calling `render()` with no context on a template that uses {{
> csrf_token }} results in an exception being thrown.
>
> I believe the appropriate fix is to change:
>
> if "CSRF_COOKIE" not in request.META:
>
> to:
>
> if not request or not request.META or "CSRF_COOKIE" not in
> request.META:
>
> I am happy to create a PR for this issue once I know it is a desired fix.
New description:
Using calling `render()` with no context on a template that uses `{{
csrf_token }}` results in an exception being thrown.
I believe the appropriate fix is to change:
`if "CSRF_COOKIE" not in request.META:`
to:
`if not request or not request.META or "CSRF_COOKIE" not in request.META:`
I am happy to create a PR for this issue once I know it is a desired fix.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29785#comment:1>
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/067.bba242a4686c53a4e24ace0f6610574b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.