diff options
| author | Marten Kenbeek <marten.knbk@gmail.com> | 2015-06-25 18:49:50 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-07-27 09:14:48 -0400 |
| commit | bc7923beffea3c51271935cad1371a67c5fcc71b (patch) | |
| tree | 09d00a16b1b0ef9d4f25ae4480142d4108d2c9db /docs | |
| parent | 6024fd5dc2022f3724ea6440c319440d457a7366 (diff) | |
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.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.9.txt | 6 | ||||
| -rw-r--r-- | docs/topics/http/urls.txt | 29 |
2 files changed, 21 insertions, 14 deletions
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 3c35ea23a2..eecf86325c 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -895,6 +895,12 @@ Miscellaneous whitespace by default. This can be disabled by setting the new :attr:`~django.forms.CharField.strip` argument to ``False``. +* If neither :attr:`request.current_app <django.http.HttpRequest.current_app>` + nor :class:`Context.current_app <django.template.Context>` are set, the + :ttag:`url` template tag will now use the namespace of the current request. + Set ``request.current_app`` to ``None`` if you don't want to use a namespace + hint. + .. _deprecated-features-1.9: Features deprecated in 1.9 diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt index 79b06dae15..ebdab6c717 100644 --- a/docs/topics/http/urls.txt +++ b/docs/topics/http/urls.txt @@ -669,11 +669,16 @@ the fully qualified name into parts and then tries the following lookup: example, ``'polls'``). This will yield a list of instances of that application. -2. If there is a *current* application defined, Django finds and returns - the URL resolver for that instance. The *current* application can be - specified as an attribute on the request. Applications that expect to - have multiple deployments should set the ``current_app`` attribute on - the ``request`` being processed. +2. If there is a current application defined, Django finds and returns the URL + resolver for that instance. The current application can be specified with + the ``current_app`` argument to the + :func:`~django.core.urlresolvers.reverse()` function. + + The :ttag:`url` template tag uses the namespace of the currently resolved + view as the current application in a + :class:`~django.template.RequestContext`. You can override this default by + setting the current application on the :attr:`request.current_app + <django.http.HttpRequest.current_app>` attribute. .. versionchanged:: 1.8 @@ -682,8 +687,11 @@ the fully qualified name into parts and then tries the following lookup: :class:`~django.template.RequestContext` that is used to render a template. - The current application can also be specified manually as an argument - to the :func:`~django.core.urlresolvers.reverse` function. + .. versionchanged:: 1.9 + + Previously, the :ttag:`url` template tag did not use the namespace of the + currently resolved view and you had to set the ``current_app`` attribute + on the request. 3. If there is no current application. Django looks for a default application instance. The default application instance is the instance @@ -751,13 +759,6 @@ Using this setup, the following lookups are possible: {% url 'polls:index' %} - Note that reversing in the template requires the ``current_app`` be added as - an attribute to the ``request`` like this:: - - 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) - * If there is no current instance - say, if we were rendering a page somewhere else on the site - ``'polls:index'`` will resolve to the last registered instance of ``polls``. Since there is no default instance |
