#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             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  1
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 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>
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/052.e221ed212c4298c6da26cc549fe925f6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to