0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Fixed #17568 -- Mentioned `reverse_lazy in the LOGIN_REDIRECT_URL` settings docs. Thanks, zsiciarz.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17626 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2012-03-02 16:56:04 +00:00
parent 4887a8de17
commit d93a2ef887
2 changed files with 28 additions and 0 deletions

View File

@ -1339,6 +1339,26 @@ The URL where requests are redirected after login when the
This is used by the :func:`~django.contrib.auth.decorators.login_required`
decorator, for example.
.. _`note on LOGIN_REDIRECT_URL setting`:
.. note::
You can use :func:`~django.core.urlresolvers.reverse_lazy` to reference
URLs by their name instead of providing a hardcoded value. Assuming a
``urls.py`` with an URL pattern named ``home``::
urlpatterns = patterns('',
url('^welcome/$', 'test_app.views.home', name='home'),
)
You can use :func:`~django.core.urlresolvers.reverse_lazy` like this::
from django.core.urlresolvers import reverse_lazy
LOGIN_REDIRECT_URL = reverse_lazy('home')
This also works fine with localized URLs using
:func:`~django.conf.urls.i18n.i18n_patterns`.
.. setting:: LOGIN_URL
LOGIN_URL
@ -1349,6 +1369,9 @@ Default: ``'/accounts/login/'``
The URL where requests are redirected for login, especially when using the
:func:`~django.contrib.auth.decorators.login_required` decorator.
.. note::
See the `note on LOGIN_REDIRECT_URL setting`_
.. setting:: LOGOUT_URL
LOGOUT_URL
@ -1358,6 +1381,9 @@ Default: ``'/accounts/logout/'``
LOGIN_URL counterpart.
.. note::
See the `note on LOGIN_REDIRECT_URL setting`_
.. setting:: MANAGERS
MANAGERS

View File

@ -888,6 +888,8 @@ reverse_lazy()
A lazily evaluated version of `reverse()`_.
.. function:: reverse_lazy(viewname, [urlconf=None, args=None, kwargs=None, current_app=None])
It is useful for when you need to use a URL reversal before your project's
URLConf is loaded. Some common cases where this function is necessary are: