Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Jannis Leidel authored
26  docs/ref/settings.txt
@@ -1339,6 +1339,26 @@ The URL where requests are redirected after login when the
1339 1339
 This is used by the :func:`~django.contrib.auth.decorators.login_required`
1340 1340
 decorator, for example.
1341 1341
 
  1342
+.. _`note on LOGIN_REDIRECT_URL setting`:
  1343
+
  1344
+.. note::
  1345
+    You can use :func:`~django.core.urlresolvers.reverse_lazy` to reference
  1346
+    URLs by their name instead of providing a hardcoded value. Assuming a
  1347
+    ``urls.py`` with an URL pattern named ``home``::
  1348
+
  1349
+        urlpatterns = patterns('',
  1350
+            url('^welcome/$', 'test_app.views.home', name='home'),
  1351
+        )
  1352
+
  1353
+    You can use :func:`~django.core.urlresolvers.reverse_lazy` like this::
  1354
+
  1355
+        from django.core.urlresolvers import reverse_lazy
  1356
+
  1357
+        LOGIN_REDIRECT_URL = reverse_lazy('home')
  1358
+
  1359
+    This also works fine with localized URLs using
  1360
+    :func:`~django.conf.urls.i18n.i18n_patterns`.
  1361
+
1342 1362
 .. setting:: LOGIN_URL
1343 1363
 
1344 1364
 LOGIN_URL
@@ -1349,6 +1369,9 @@ Default: ``'/accounts/login/'``
1349 1369
 The URL where requests are redirected for login, especially when using the
1350 1370
 :func:`~django.contrib.auth.decorators.login_required` decorator.
1351 1371
 
  1372
+.. note::
  1373
+    See the `note on LOGIN_REDIRECT_URL setting`_
  1374
+
1352 1375
 .. setting:: LOGOUT_URL
1353 1376
 
1354 1377
 LOGOUT_URL
@@ -1358,6 +1381,9 @@ Default: ``'/accounts/logout/'``
1358 1381
 
1359 1382
 LOGIN_URL counterpart.
1360 1383
 
  1384
+.. note::
  1385
+    See the `note on LOGIN_REDIRECT_URL setting`_
  1386
+
1361 1387
 .. setting:: MANAGERS
1362 1388
 
1363 1389
 MANAGERS
2  docs/topics/http/urls.txt
@@ -888,6 +888,8 @@ reverse_lazy()
888 888
 
889 889
 A lazily evaluated version of `reverse()`_.
890 890
 
  891
+.. function:: reverse_lazy(viewname, [urlconf=None, args=None, kwargs=None, current_app=None])
  892
+
891 893
 It is useful for when you need to use a URL reversal before your project's
892 894
 URLConf is loaded. Some common cases where this function is necessary are:
893 895
 

0 notes on commit d93a2ef

Please sign in to comment.
Something went wrong with that request. Please try again.