Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Create headings and expand CBV docs so that the "Built-In CBV" docs incl... #261

Merged
merged 1 commit into from

2 participants

@issackelly

Create headings and expand CBV docs so that the "Built-In CBV" docs include a complete list.

The complete list is preferred so that a single list exists to find any CBV. The previous break-up of this list has made browsing slightly more difficult.

@timgraham timgraham merged commit 4eaf73d into django:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 11, 2012
  1. @issackelly
This page is out of date. Refresh to see the latest.
View
35 docs/ref/class-based-views/base.txt
@@ -8,6 +8,9 @@ themselves or inherited from. They may not provide all the capabilities
required for projects, in which case there are Mixins and Generic class-based
views.
+View
+----
+
.. class:: django.views.generic.base.View
The master class-based base view. All other class-based views inherit from
@@ -31,13 +34,13 @@ views.
**Example urls.py**::
from django.conf.urls import patterns, url
-
+
from myapp.views import MyView
-
+
urlpatterns = patterns('',
url(r'^mine/$', MyView.as_view(), name='my-view'),
)
-
+
**Methods**
.. method:: dispatch(request, *args, **kwargs)
@@ -61,13 +64,16 @@ views.
The default implementation returns ``HttpResponseNotAllowed`` with list
of allowed methods in plain text.
-
- .. note::
+
+ .. note::
Documentation on class-based views is a work in progress. As yet, only the
methods defined directly on the class are documented here, not methods
defined on superclasses.
+TemplateView
+------------
+
.. class:: django.views.generic.base.TemplateView
Renders a given template, passing it a ``{{ params }}`` template variable,
@@ -84,22 +90,22 @@ views.
1. :meth:`dispatch()`
2. :meth:`http_method_not_allowed()`
3. :meth:`get_context_data()`
-
+
**Example views.py**::
from django.views.generic.base import TemplateView
-
+
from articles.models import Article
class HomePageView(TemplateView):
template_name = "home.html"
-
+
def get_context_data(self, **kwargs):
context = super(HomePageView, self).get_context_data(**kwargs)
context['latest_articles'] = Article.objects.all()[:5]
return context
-
+
**Example urls.py**::
from django.conf.urls import patterns, url
@@ -126,12 +132,15 @@ views.
* ``params``: The dictionary of keyword arguments captured from the URL
pattern that served the view.
- .. note::
+ .. note::
Documentation on class-based views is a work in progress. As yet, only the
methods defined directly on the class are documented here, not methods
defined on superclasses.
+RedirectView
+------------
+
.. class:: django.views.generic.base.RedirectView
Redirects to a given URL.
@@ -159,7 +168,7 @@ views.
from django.shortcuts import get_object_or_404
from django.views.generic.base import RedirectView
-
+
from articles.models import Article
class ArticleCounterRedirectView(RedirectView):
@@ -176,7 +185,7 @@ views.
from django.conf.urls import patterns, url
from django.views.generic.base import RedirectView
-
+
from article.views import ArticleCounterRedirectView
urlpatterns = patterns('',
@@ -217,7 +226,7 @@ views.
behavior they wish, as long as the method returns a redirect-ready URL
string.
- .. note::
+ .. note::
Documentation on class-based views is a work in progress. As yet, only the
methods defined directly on the class are documented here, not methods
View
24 docs/ref/class-based-views/generic-date-based.txt
@@ -5,6 +5,9 @@ Generic date views
Date-based generic views (in the module :mod:`django.views.generic.dates`)
are views for displaying drilldown pages for date-based data.
+ArchiveIndexView
+----------------
+
.. class:: django.views.generic.dates.ArchiveIndexView
A top-level index page showing the "latest" objects, by date. Objects with
@@ -21,12 +24,15 @@ are views for displaying drilldown pages for date-based data.
* :class:`django.views.generic.list.MultipleObjectMixin`
* :class:`django.views.generic.dates.DateMixin`
* :class:`django.views.generic.base.View`
-
+
**Notes**
* Uses a default ``context_object_name`` of ``latest``.
* Uses a default ``template_name_suffix`` of ``_archive``.
+YearArchiveView
+---------------
+
.. class:: django.views.generic.dates.YearArchiveView
A yearly archive page showing all available months in a given year. Objects
@@ -86,6 +92,9 @@ are views for displaying drilldown pages for date-based data.
* Uses a default ``template_name_suffix`` of ``_archive_year``.
+MonthArchiveView
+----------------
+
.. class:: django.views.generic.dates.MonthArchiveView
A monthly archive page showing all objects in a given month. Objects with a
@@ -134,6 +143,9 @@ are views for displaying drilldown pages for date-based data.
* Uses a default ``template_name_suffix`` of ``_archive_month``.
+WeekArchiveView
+---------------
+
.. class:: django.views.generic.dates.WeekArchiveView
A weekly archive page showing all objects in a given week. Objects with a
@@ -175,6 +187,9 @@ are views for displaying drilldown pages for date-based data.
* Uses a default ``template_name_suffix`` of ``_archive_week``.
+DayArchiveView
+--------------
+
.. class:: django.views.generic.dates.DayArchiveView
A day archive page showing all objects in a given day. Days in the future
@@ -225,6 +240,9 @@ are views for displaying drilldown pages for date-based data.
* Uses a default ``template_name_suffix`` of ``_archive_day``.
+TodayArchiveView
+----------------
+
.. class:: django.views.generic.dates.TodayArchiveView
A day archive page showing all objects for *today*. This is exactly the
@@ -246,6 +264,10 @@ are views for displaying drilldown pages for date-based data.
* :class:`django.views.generic.dates.DateMixin`
* :class:`django.views.generic.base.View`
+
+DateDetailView
+--------------
+
.. class:: django.views.generic.dates.DateDetailView
A page representing an individual object. If the object has a date value in
View
10 docs/ref/class-based-views/generic-display.txt
@@ -5,6 +5,9 @@ Generic display views
The two following generic class-based views are designed to display data. On
many projects they are typically the most commonly used views.
+DetailView
+----------
+
.. class:: django.views.generic.detail.DetailView
While this view is executing, ``self.object`` will contain the object that
@@ -39,7 +42,7 @@ many projects they are typically the most commonly used views.
from articles.models import Article
class ArticleDetailView(DetailView):
-
+
model = Article
def get_context_data(self, **kwargs):
@@ -55,7 +58,10 @@ many projects they are typically the most commonly used views.
urlpatterns = patterns('',
url(r'^(?P<slug>[-_\w]+)/$', ArticleDetailView.as_view(), name='article-detail'),
- )
+ )
+
+ListView
+--------
.. class:: django.views.generic.list.ListView
View
27 docs/ref/class-based-views/generic-editing.txt
@@ -2,7 +2,7 @@
Generic editing views
=====================
-The following views are described on this page and provide a foundation for
+The following views are described on this page and provide a foundation for
editing content:
* :class:`django.views.generic.edit.FormView`
@@ -13,7 +13,7 @@ editing content:
.. note::
Some of the examples on this page assume that a model titled 'Author'
- has been defined. For these cases we assume the following has been defined
+ has been defined. For these cases we assume the following has been defined
in `myapp/models.py`::
from django import models
@@ -25,6 +25,9 @@ editing content:
def get_absolute_url(self):
return reverse('author-detail', kwargs={'pk': self.pk})
+FormView
+--------
+
.. class:: django.views.generic.edit.FormView
A view that displays a form. On error, redisplays the form with validation
@@ -69,6 +72,8 @@ editing content:
form.send_email()
return super(ContactView, self).form_valid(form)
+CreateView
+----------
.. class:: django.views.generic.edit.CreateView
@@ -94,7 +99,7 @@ editing content:
.. attribute:: template_name_suffix
The CreateView page displayed to a GET request uses a
- ``template_name_suffix`` of ``'_form.html'``. For
+ ``template_name_suffix`` of ``'_form.html'``. For
example, changing this attribute to ``'_create_form.html'`` for a view
creating objects for the the example `Author` model would cause the the
default `template_name` to be ``'myapp/author_create_form.html'``.
@@ -107,6 +112,9 @@ editing content:
class AuthorCreate(CreateView):
model = Author
+UpdateView
+----------
+
.. class:: django.views.generic.edit.UpdateView
A view that displays a form for editing an existing object, redisplaying
@@ -133,10 +141,10 @@ editing content:
.. attribute:: template_name_suffix
The UpdateView page displayed to a GET request uses a
- ``template_name_suffix`` of ``'_form.html'``. For
+ ``template_name_suffix`` of ``'_form.html'``. For
example, changing this attribute to ``'_update_form.html'`` for a view
updating objects for the the example `Author` model would cause the the
- default `template_name` to be ``'myapp/author_update_form.html'``.
+ default `template_name` to be ``'myapp/author_update_form.html'``.
**Example views.py**::
@@ -146,6 +154,9 @@ editing content:
class AuthorUpdate(UpdateView):
model = Author
+DeleteView
+----------
+
.. class:: django.views.generic.edit.DeleteView
A view that displays a confirmation page and deletes an existing object.
@@ -171,10 +182,10 @@ editing content:
.. attribute:: template_name_suffix
The DeleteView page displayed to a GET request uses a
- ``template_name_suffix`` of ``'_confirm_delete.html'``. For
+ ``template_name_suffix`` of ``'_confirm_delete.html'``. For
example, changing this attribute to ``'_check_delete.html'`` for a view
deleting objects for the the example `Author` model would cause the the
- default `template_name` to be ``'myapp/author_check_delete.html'``.
+ default `template_name` to be ``'myapp/author_check_delete.html'``.
**Example views.py**::
@@ -185,4 +196,4 @@ editing content:
class AuthorDelete(DeleteView):
model = Author
- success_url = reverse_lazy('author-list')
+ success_url = reverse_lazy('author-list')
View
2  docs/ref/class-based-views/index.txt
@@ -6,7 +6,7 @@ Class-based views API reference. For introductory material, see
:doc:`/topics/class-based-views/index`.
.. toctree::
- :maxdepth: 1
+ :maxdepth: 3
base
generic-display
View
18 docs/ref/class-based-views/mixins-date-based.txt
@@ -3,6 +3,9 @@ Date-based mixins
=================
+YearMixin
+---------
+
.. class:: django.views.generic.dates.YearMixin
A mixin that can be used to retrieve and provide parsing information for a
@@ -36,6 +39,9 @@ Date-based mixins
Raises a 404 if no valid year specification can be found.
+MonthMixin
+----------
+
.. class:: django.views.generic.dates.MonthMixin
A mixin that can be used to retrieve and provide parsing information for a
@@ -82,6 +88,9 @@ Date-based mixins
date provided. If ``allow_empty = False``, returns the previous month
that contained data.
+DayMixin
+--------
+
.. class:: django.views.generic.dates.DayMixin
A mixin that can be used to retrieve and provide parsing information for a
@@ -127,6 +136,9 @@ Date-based mixins
Returns a date object containing the previous day. If
``allow_empty = False``, returns the previous day that contained data.
+WeekMixin
+---------
+
.. class:: django.views.generic.dates.WeekMixin
A mixin that can be used to retrieve and provide parsing information for a
@@ -161,6 +173,9 @@ Date-based mixins
Raises a 404 if no valid week specification can be found.
+DateMixin
+---------
+
.. class:: django.views.generic.dates.DateMixin
A mixin class providing common behavior for all date-based views.
@@ -204,6 +219,9 @@ Date-based mixins
is greater than the current date/time. Returns
:attr:`DateMixin.allow_future` by default.
+BaseDateListView
+----------------
+
.. class:: django.views.generic.dates.BaseDateListView
A base class that provides common behavior for all date-based views. There
View
14 docs/ref/class-based-views/mixins-editing.txt
@@ -14,6 +14,9 @@ The following mixins are used to construct Django's editing views:
Examples of how these are combined into editing views can be found at
the documentation on ``Generic editing views``.
+FormMixin
+---------
+
.. class:: django.views.generic.edit.FormMixin
A mixin class that provides facilities for creating and displaying forms.
@@ -90,6 +93,9 @@ The following mixins are used to construct Django's editing views:
:meth:`~django.views.generic.FormMixin.form_invalid`.
+ModelFormMixin
+--------------
+
.. class:: django.views.generic.edit.ModelFormMixin
A form mixin that works on ModelForms, rather than a standalone form.
@@ -147,12 +153,16 @@ The following mixins are used to construct Django's editing views:
.. method:: form_invalid()
Renders a response, providing the invalid form as context.
-
+
+
+ProcessFormView
+---------------
+
.. class:: django.views.generic.edit.ProcessFormView
A mixin that provides basic HTTP GET and POST workflow.
- .. note::
+ .. note::
This is named 'ProcessFormView' and inherits directly from
:class:`django.views.generic.base.View`, but breaks if used
View
6 docs/ref/class-based-views/mixins-multiple-object.txt
@@ -2,6 +2,9 @@
Multiple object mixins
======================
+MultipleObjectMixin
+-------------------
+
.. class:: django.views.generic.list.MultipleObjectMixin
A mixin that can be used to display a list of objects.
@@ -148,6 +151,9 @@ Multiple object mixins
this context variable will be ``None``.
+MultipleObjectTemplateResponseMixin
+-----------------------------------
+
.. class:: django.views.generic.list.MultipleObjectTemplateResponseMixin
A mixin class that performs template-based response rendering for views
View
6 docs/ref/class-based-views/mixins-simple.txt
@@ -2,6 +2,9 @@
Simple mixins
=============
+ContextMixin
+------------
+
.. class:: django.views.generic.base.ContextMixin
.. versionadded:: 1.5
@@ -17,6 +20,9 @@ Simple mixins
Returns a dictionary representing the template context. The
keyword arguments provided will make up the returned context.
+TemplateResponseMixin
+---------------------
+
.. class:: django.views.generic.base.TemplateResponseMixin
Provides a mechanism to construct a
View
6 docs/ref/class-based-views/mixins-single-object.txt
@@ -2,6 +2,9 @@
Single object mixins
====================
+SingleObjectMixin
+-----------------
+
.. class:: django.views.generic.detail.SingleObjectMixin
Provides a mechanism for looking up an object associated with the
@@ -86,6 +89,9 @@ Single object mixins
``context_object_name`` is specified, that variable will also be
set in the context, with the same value as ``object``.
+SingleObjectTemplateResponseMixin
+---------------------------------
+
.. class:: django.views.generic.detail.SingleObjectTemplateResponseMixin
A mixin class that performs template-based response rendering for views
Something went wrong with that request. Please try again.