Ticket #5394: authentication-docs.diff

File authentication-docs.diff, 1.3 KB (added by DavidReynolds, 7 years ago)

update authentication docs

  • docs/authentication.txt

     
    402402    def my_view(request):
    403403        # ...
    404404
     405``login_required`` also takes an optional ``redirect_field_name`` parameter. Example::
     406   
     407    from django.contrib.auth.decorators import login_required
     408
     409    def my_view(request):
     410        # ...
     411    my_view = login_required(redirect_field_name='redirect_to')(my_view)
     412
     413Again, an equivalent example of the more compact decorator syntax introduced in Python 2.4::
     414   
     415    from django.contrib.auth.decorators import login_required
     416
     417    @login_required(redirect_field_name='redirect_to')
     418    def my_view(request):
     419        # ...
     420
    405421``login_required`` does the following:
    406422
    407423    * If the user isn't logged in, redirect to ``settings.LOGIN_URL``
    408424      (``/accounts/login/`` by default), passing the current absolute URL
    409       in the query string as ``next``. For example:
     425      in the query string as ``next`` or the value of ``redirect_field_name``.
     426      For example:
    410427      ``/accounts/login/?next=/polls/3/``.
    411428    * If the user is logged in, execute the view normally. The view code is
    412429      free to assume the user is logged in.
Back to Top