Ticket #22006: ticket-22006.diff

File ticket-22006.diff, 811 bytes (added by chrismarceloph, 11 years ago)
  • docs/topics/auth/default.txt

    diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt
    index 5d93e43..97641d2 100644
    a b To apply a permission to a :doc:`class-based generic view  
    572572<django.views.generic.base.View.dispatch>` method on the class. See
    573573:ref:`decorating-class-based-views` for details.
    574574
     575If you have many generic views that should be decorated with :func:`~django.contrib.auth.decorators.login_required`, an alternative is to implement a mixin, like this::
     576
     577    class LoginRequiredMixin(object):
     578        def as_view(cls):
     579            return login_required(super(LoginRequiredMixin, cls).as_view())
     580
     581    class MyView(LoginRequiredMixin, ...):
     582        # this is a generic view
     583        ...
    575584
    576585.. _built-in-auth-views:
    577586
Back to Top