Opened 6 years ago
Last modified 6 years ago
#29785 closed Bug
Using {{ csrf_token }} throws exception (AttributeError: 'dict' object has no attribute 'META') if no render context — at Version 1
Reported by: | jeffrey k eliasen | Owned by: | nobody |
---|---|---|---|
Component: | CSRF | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
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.
Note:
See TracTickets
for help on using tickets.