Ticket #15715: perm-reqd-example.patch

File perm-reqd-example.patch, 834 bytes (added by Dan McGee, 14 years ago)

Possible documentation update

  • docs/topics/class-based-views.txt

     
    570570The easiest place to do this is in the URLconf where you deploy your
    571571view::
    572572
    573     from django.contrib.auth.decorators import login_required
     573    from django.contrib.auth.decorators import login_required, permission_required
    574574    from django.views.generic import TemplateView
    575575
     576    from .views import VoteView
     577
    576578    urlpatterns = patterns('',
    577579        (r'^about/',login_required(TemplateView.as_view(template_name="secret.html"))),
     580        (r'^vote/',permission_required('polls.can_vote')(VoteView.as_view())),
    578581    )
    579582
    580583This approach applies the decorator on a per-instance basis. If you
Back to Top