Opened 11 years ago
Closed 10 years ago
#24127 closed New feature (fixed)
Automatically set the current URL namespace based on the URL of the current request
| Reported by: | Aymeric Augustin | Owned by: | Marten Kenbeek |
|---|---|---|---|
| Component: | Core (URLs) | Version: | dev |
| Severity: | Normal | Keywords: | current_app |
| Cc: | marten.knbk@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The documentation on URL namespaces shows the following example:
def render_to_response(self, context, **response_kwargs):
self.request.current_app = self.request.resolver_match.namespace
return super(DetailView, self).render_to_response(context, **response_kwargs)
self.request.current_app = self.request.resolver_match.namespace looks like something that makes sense in general and could be done automatically for all requests.
This became possible in Django 1.8 because current_app is now an attribute of the request object.
There are some fairly obvious backwards-compatibility concerns, but this change looks like it could save a lot of boilerplate code.
Change History (11)
comment:1 by , 11 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 11 years ago
| Keywords: | multiple-template-engines removed |
|---|
comment:3 by , 11 years ago
| Keywords: | current_app added |
|---|
comment:4 by , 10 years ago
| Cc: | added |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
comment:5 by , 10 years ago
Marten, do you plan to move forward with this ticket? It should ease the deprecation in #24126 a bit as I noted there, I think.
comment:9 by , 10 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
comment:10 by , 10 years ago
| Needs tests: | unset |
|---|
I felt awkward when I added that documentation.