Ticket #17568: 17568_2.diff

File 17568_2.diff, 1.8 KB (added by Zbigniew Siciarz, 13 years ago)

Link to reverse_lazy. Also changed the example to use regular patterns() instead of i18n_patterns(), as these are mentioned at the end of the note.

  • docs/ref/settings.txt

    diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
    index d8260b0..71adff7 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:`~django.core.urlresolvers.reverse_lazy` to reference
     1310    URLs by their name instead of providing hardcoded value::
     1311
     1312        # urls.py
     1313        urlpatterns = 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    This also works fine with localized URLs using :func:`~django.conf.urls.i18n.i18n_patterns`.
     1321
    13061322.. setting:: LOGIN_URL
    13071323
    13081324LOGIN_URL
    Default: ``'/accounts/login/'``  
    13131329The URL where requests are redirected for login, especially when using the
    13141330:func:`~django.contrib.auth.decorators.login_required` decorator.
    13151331
     1332.. note::
     1333    See the `note on LOGIN_REDIRECT_URL setting`_
     1334
    13161335.. setting:: LOGOUT_URL
    13171336
    13181337LOGOUT_URL
    Default: ``'/accounts/logout/'``  
    13221341
    13231342LOGIN_URL counterpart.
    13241343
     1344.. note::
     1345    See the `note on LOGIN_REDIRECT_URL setting`_
     1346
    13251347.. setting:: MANAGERS
    13261348
    13271349MANAGERS
  • docs/topics/http/urls.txt

    diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
    index 29ee851..fe90bbc 100644
    a b reverse_lazy()  
    880880
    881881A lazily evaluated version of `reverse()`_.
    882882
     883.. function:: reverse_lazy(viewname, [urlconf=None, args=None, kwargs=None, current_app=None])
     884
    883885It is useful for when you need to use a URL reversal before your project's
    884886URLConf is loaded. Some common cases where this function is necessary are:
    885887
Back to Top