summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSimon Meers <simon@simonmeers.com>2011-07-10 21:39:18 +0000
committerSimon Meers <simon@simonmeers.com>2011-07-10 21:39:18 +0000
commit4d920c5ecdac9ebb96ff88955a0ff0b7a3616fc6 (patch)
treea1396bcde17fa203bc2397bf9762a23acb8bc2c9 /docs
parent8d6c2dad9dd4cf607a325255d65edb79a44dc8eb (diff)
Fixed #15715 -- added non-trivial decorator example to CBV docs. Thanks toofishes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16534 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/class-based-views.txt7
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt
index a13f18993d..8092cb29af 100644
--- a/docs/topics/class-based-views.txt
+++ b/docs/topics/class-based-views.txt
@@ -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