Skip to content

Commit

Permalink
[1.3.X] Fixed #15715 -- added non-trivial decorator example to CBV do…
Browse files Browse the repository at this point in the history
…cs. Thanks toofishes.

Backport of r16534 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16535 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
DrMeers committed Jul 10, 2011
1 parent 00886df commit c828cc1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/topics/class-based-views.txt
Expand Up @@ -570,11 +570,14 @@ result of the :meth:`~django.views.generic.base.View.as_view` method.
The easiest place to do this is in the URLconf where you deploy your
view::

from django.contrib.auth.decorators import login_required
from django.contrib.auth.decorators import login_required, permission_required
from django.views.generic import TemplateView

from .views import VoteView

urlpatterns = patterns('',
(r'^about/',login_required(TemplateView.as_view(template_name="secret.html"))),
(r'^about/', login_required(TemplateView.as_view(template_name="secret.html"))),
(r'^vote/', permission_required('polls.can_vote')(VoteView.as_view())),
)

This approach applies the decorator on a per-instance basis. If you
Expand Down

0 comments on commit c828cc1

Please sign in to comment.