Ticket #17568: 17568.diff

File 17568.diff, 1.3 KB (added by neaf, 13 years ago)

Add hint to documentation about using reverse_lazy.

  • docs/ref/settings.txt

    diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
    index d8260b0..f5d0f9a 100644
    a b The URL where requests are redirected after login when the  
    13031303This is used by the :func:`~django.contrib.auth.decorators.login_required`
    13041304decorator, for example.
    13051305
     1306.. _`note on LOGIN_REDIRECT_URL setting`:
     1307
     1308.. note::
     1309    You can use :func:`~reverse_lazy` to reference
     1310    URLs by their name instead of providing hardcoded value::
     1311
     1312        # urls.py
     1313        urlpatterns = i18n_patterns('',
     1314            url(_(r'^home/$'), 'test_app.views.home', name='home'),
     1315        )
     1316
     1317        # settings.py
     1318        LOGIN_REDIRECT_URL = reverse_lazy('home')
     1319
     1320
     1321    This also works well with :func:`~django.conf.urls.i18n.i18n_patterns`.
     1322
    13061323.. setting:: LOGIN_URL
    13071324
    13081325LOGIN_URL
    Default: ``'/accounts/login/'``  
    13131330The URL where requests are redirected for login, especially when using the
    13141331:func:`~django.contrib.auth.decorators.login_required` decorator.
    13151332
     1333.. note::
     1334    See the `note on LOGIN_REDIRECT_URL setting`_
     1335
    13161336.. setting:: LOGOUT_URL
    13171337
    13181338LOGOUT_URL
    Default: ``'/accounts/logout/'``  
    13221342
    13231343LOGIN_URL counterpart.
    13241344
     1345.. note::
     1346    See the `note on LOGIN_REDIRECT_URL setting`_
     1347
    13251348.. setting:: MANAGERS
    13261349
    13271350MANAGERS
Back to Top