Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #15715 -- added non-trivial decorator example to CBV docs. Than…

…ks toofishes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16534 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4d920c5ecdac9ebb96ff88955a0ff0b7a3616fc6 1 parent 8d6c2da
Simon Meers DrMeers authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 docs/topics/class-based-views.txt
7 docs/topics/class-based-views.txt
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.