#36909: Avoid using context.request directly in querystring template tag
-------------------------------------+-------------------------------------
Reporter: Jake Howard | Owner: Yogya
| Chugh
Type: Bug | Status: assigned
Component: Template system | Version: 5.1
Severity: Normal | Resolution:
Keywords: querystring | Triage Stage: Accepted
requestcontext |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Yogya Chugh ):
I have replaced the request attribute with `context["request"]` in
`querystring` and added 3 testcases and updated 1 for checking
compatibility with `Context` object rather than being specific to
`RequestContext`.
But,
As seen in the PR too, there is 1 testcase failing ( see below ) leading
to a lot of failed checks. It's main cause is the "request" key added to
context.
The test case fails on last line {{{ self.assertContains(response, '<a
href="%s">Users</a>' % url) }}} as it returns with an aria-current
attribute due to the request.
So should I go forward with setting `context["_request"]` instead as it
passes all tests but i feel it's temporary ?
( About the linter issues, fixed but will be added in next commit )
{{{
@override_settings(
TEMPLATES=[
{
"BACKEND":
"django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
}
]
)
def
test_sidebar_aria_current_page_missing_without_request_context_processor(self):
url = reverse("test_with_sidebar:auth_user_changelist")
response = self.client.get(url)
self.assertContains(
response, '<nav class="sticky" id="nav-sidebar" aria-
label="Sidebar">'
)
# Does not include aria-current attribute.
self.assertContains(response, '<a href="%s">Users</a>' % url)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36909#comment:16>
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 view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019c6ba411e4-ece5f08c-6298-4425-94b5-53623aa2634c-000000%40eu-central-1.amazonses.com.