#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:  closed
    Component:  CSRF               |                  Version:  master
     Severity:  Normal             |               Resolution:  invalid
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  1                  |                    UI/UX:  0
-----------------------------------+--------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 From the [https://docs.djangoproject.com/en/2.1/ref/csrf/#how-to-use-it
 CSRF docs]:

 > In the corresponding view functions, ensure that RequestContext is used
 to render the response so that {% csrf_token %} will work properly.

 The `request` is required in the context.

 (If you're looking to render your template in a true non-request context,
 you can use `RequestFactory` to generate a placeholder and add `
 'csrf_token': 'NOTPROVIDED'` to the context in order to short circuit the
 CSRF input rendering.)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29785#comment:3>
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.9a4184ba453e92111a4598c7841e0d2e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to