#36909: Avoid using context.request directly
-----------------------------+-------------------------------------------
Reporter: Jake Howard | Type: Bug
Status: new | Component: Template system
Version: 5.1 | 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
-----------------------------+-------------------------------------------
The `RequestContext` subclass sets `context.request` to the current
request object. This attribute isn't available when `Context` is used, or
when something context-looking is used instead. For example, the new
`querystring` tag accesses `context.request`, making it incompatible in
some cases.
I'd suggest that uses of `context.request` directly be replaced with
`context["request"]`, and that `RequestContext` automatically add
`request` to its own context if it's not there already. It might also be
worth renaming the attribute to `_request` to hint it shouldn't be used
externally.
This likely only occurs when template context is being incorrectly
handled, but it's likely worth improving regardless.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36909>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.