Ticket #22006: ticket-22006-fixed.diff

File ticket-22006-fixed.diff, 852 bytes (added by mockforest, 11 years ago)

added @classmethod

  • docs/topics/auth/default.txt

    diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt
    index 5d93e43..a5fc4ed 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        @classmethod
     579        def as_view(cls):
     580            return login_required(super(LoginRequiredMixin, cls).as_view())
     581
     582    class MyView(LoginRequiredMixin, ...):
     583        # this is a generic view
     584        ...
    575585
    576586.. _built-in-auth-views:
    577587
Back to Top