mirror of https://github.com/django/django.git
Fixed #19335 - Typo and cleanups in docs/topics/class-based-views/index.txt
This commit is contained in:
parent
978d4476cf
commit
e2b1808196
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue