Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #17568 -- Mentioned ``reverse_lazy`` in the ``LOGIN_REDIRECT_UR…

…L`` settings docs. Thanks, zsiciarz.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17626 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d93a2ef887e353192ff8b0a7a5271ad80abf2b52 1 parent 4887a8d
@jezdez jezdez authored
Showing with 28 additions and 0 deletions.
  1. +26 −0 docs/ref/settings.txt
  2. +2 −0  docs/topics/http/urls.txt
View
26 docs/ref/settings.txt
@@ -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
2  docs/topics/http/urls.txt
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.