diff options
| author | Tim Graham <timograham@gmail.com> | 2012-11-21 19:06:17 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2012-11-21 19:07:36 -0500 |
| commit | 6d1307102104d5982e5dc8c3485ffd7bfdb658d3 (patch) | |
| tree | 642883688404b1eab10cfff599a6db09da706bb2 /docs | |
| parent | 49484b54bc26122257ac73b059897870d6ef716f (diff) | |
[1.5.X] Fixed #19335 - Typo and cleanups in docs/topics/class-based-views/index.txt
Backport of e2b1808196 from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/class-based-views/index.txt | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/docs/topics/class-based-views/index.txt b/docs/topics/class-based-views/index.txt index a738221892..54d4b0f252 100644 --- a/docs/topics/class-based-views/index.txt +++ b/docs/topics/class-based-views/index.txt @@ -24,9 +24,9 @@ Basic examples Django provides base view classes which will suit a wide range of applications. All views inherit from the :class:`~django.views.generic.base.View` class, which handles linking the view in to the URLs, HTTP method dispatching and other -simple features. :class:`~django.views.generic.base.RedirectView` is for a simple HTTP -redirect, and :class:`~django.views.generic.base.TemplateView` extends the base class -to make it also render a template. +simple features. :class:`~django.views.generic.base.RedirectView` is for a +simple HTTP redirect, and :class:`~django.views.generic.base.TemplateView` +extends the base class to make it also render a template. Simple usage in your URLconf @@ -34,7 +34,8 @@ Simple usage in your URLconf The simplest way to use generic views is to create them directly in your URLconf. If you're only changing a few simple attributes on a class-based view, -you can simply pass them into the ``as_view`` method call itself:: +you can simply pass them into the +:meth:`~django.views.generic.base.View.as_view` method call itself:: from django.conf.urls import patterns, url, include from django.views.generic import TemplateView @@ -43,9 +44,10 @@ you can simply pass them into the ``as_view`` method call itself:: (r'^about/', TemplateView.as_view(template_name="about.html")), ) -Any arguments given will override the ``template_name`` on the -A similar overriding pattern can be used for the ``url`` attribute on -:class:`~django.views.generic.base.RedirectView`. +Any arguments passed to :meth:`~django.views.generic.base.View.as_view` will +override attributes set on the class. In this example, we set ``template_name`` +on the ``TemplateView``. A similar overriding pattern can be used for the +``url`` attribute on :class:`~django.views.generic.base.RedirectView`. Subclassing generic views @@ -67,8 +69,8 @@ and override the template name:: Then we just need to add this new view into our URLconf. `~django.views.generic.base.TemplateView` is a class, not a function, so we -point the URL to the ``as_view`` class method instead, which provides a -function-like entry to class-based views:: +point the URL to the :meth:`~django.views.generic.base.View.as_view` class +method instead, which provides a function-like entry to class-based views:: # urls.py from django.conf.urls import patterns, url, include |
