[Django] #24127: Automatically set the current URL namespace based on the URL of the current request

16 views
Skip to first unread message

Django

unread,
Jan 11, 2015, 1:44:55 PM1/11/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New | Status: new
feature |
Component: Core | Version: master
(URLs) | Keywords: multiple-template-
Severity: Normal | engines
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The [https://docs.djangoproject.com/en/dev/topics/http/urls/#reversing-
namespaced-urls 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24127>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 12, 2015, 2:07:28 PM1/12/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: multiple-template- | Triage Stage: Accepted
engines |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


Comment:

I felt awkward when I added that documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:1>

Django

unread,
Feb 6, 2015, 12:57:05 PM2/6/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: nobody

Type: New feature | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by aaugustin):

* keywords: multiple-template-engines =>


--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:2>

Django

unread,
Feb 6, 2015, 12:57:55 PM2/6/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: nobody

Type: New feature | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by aaugustin):

* keywords: => current_app


--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:3>

Django

unread,
Jun 3, 2015, 8:22:18 AM6/3/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: assigned

Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by knbk):

* cc: marten.knbk@… (added)
* owner: nobody => knbk
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:4>

Django

unread,
Jun 23, 2015, 10:37:38 AM6/23/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by timgraham):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:5>

Django

unread,
Jun 25, 2015, 12:59:33 PM6/25/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by knbk):

Yes, working on it: https://github.com/django/django/pull/4919

--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:6>

Django

unread,
Jun 25, 2015, 2:11:18 PM6/25/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by Marten Kenbeek <marten.knbk@…>):

In [changeset:"6364df68879efc0d9451d6427e34b4542e3d7e0b" 6364df6]:
{{{
#!CommitTicketReference repository=""
revision="6364df68879efc0d9451d6427e34b4542e3d7e0b"
Refs #24127 -- Added documentation for HttpRequest.current_app.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:7>

Django

unread,
Jun 25, 2015, 2:11:31 PM6/25/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"ae93aeed2b87c4a6dd9290146aaee5dc57d07bfb" ae93aee]:
{{{
#!CommitTicketReference repository=""
revision="ae93aeed2b87c4a6dd9290146aaee5dc57d07bfb"
[1.8.x] Refs #24127 -- Added documentation for HttpRequest.current_app.

Backport of 6364df68879efc0d9451d6427e34b4542e3d7e0b from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:8>

Django

unread,
Jun 27, 2015, 9:49:12 AM6/27/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:9>

Django

unread,
Jul 26, 2015, 11:43:02 AM7/26/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: current_app | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by knbk):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:10>

Django

unread,
Jul 27, 2015, 9:16:17 AM7/27/15
to django-...@googlegroups.com
#24127: Automatically set the current URL namespace based on the URL of the current
request
-----------------------------+------------------------------------
Reporter: aaugustin | Owner: knbk
Type: New feature | Status: closed

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: fixed

Keywords: current_app | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"bc7923beffea3c51271935cad1371a67c5fcc71b" bc7923b]:
{{{
#!CommitTicketReference repository=""
revision="bc7923beffea3c51271935cad1371a67c5fcc71b"
Fixed #24127 -- Changed the default current_app to the current namespace.

Changed the url template tag to use request.resolver_match.namespace as a
default for the current_app argument if request.current_app is not set.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24127#comment:11>

Reply all
Reply to author
Forward
0 new messages