Author: jezdez Date: 2012-03-02 08:56:04 -0800 (Fri, 02 Mar 2012) New Revision: 17626
Modified: django/trunk/docs/ref/settings.txt django/trunk/docs/topics/http/urls.txt Log: Fixed #17568 -- Mentioned ``reverse_lazy`` in the ``LOGIN_REDIRECT_URL`` settings docs. Thanks, zsiciarz. Modified: django/trunk/docs/ref/settings.txt =================================================================== --- django/trunk/docs/ref/settings.txt 2012-03-02 16:55:56 UTC (rev 17625) +++ django/trunk/docs/ref/settings.txt 2012-03-02 16:56:04 UTC (rev 17626) @@ -1339,6 +1339,26 @@ 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 @@ 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 @@ LOGIN_URL counterpart. +.. note:: + See the `note on LOGIN_REDIRECT_URL setting`_ + .. setting:: MANAGERS MANAGERS Modified: django/trunk/docs/topics/http/urls.txt =================================================================== --- django/trunk/docs/topics/http/urls.txt 2012-03-02 16:55:56 UTC (rev 17625) +++ django/trunk/docs/topics/http/urls.txt 2012-03-02 16:56:04 UTC (rev 17626) @@ -888,6 +888,8 @@ 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: -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.