Skip to content
A work in progress. Hopefully not too broken. Needs documentation.
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead, 5 commits behind bfirsh:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Django class-based views

Work on ticket #6735.


$ python install

Or for the moment:

$ pip install -e


Inherit your own class-based views from existing ones listed below:

class AuthorDetail(class_based_views.DetailView):
    queryset = Author.objects.all()

You can also use the configure class method as a shortcut.

Declare your view in your URLs like you already do for classic views:

import views
from django.conf.urls.defaults import *

urlpatterns = patterns('',

Note: you must use the as_view method of the class in your URLs, not the class in order to avoid shared attributes across requests.


CRUD views

  • ListView: Render some list of objects, set by self.queryset. This can be any iterable of items, not just a queryset.

  • DetailView: Render a "detail" view of an object. By default this is a model instance looked up from self.queryset, but the view will support display of any object by overriding self.get_object().

  • CreateView: View for creating an object.

  • UpdateView: View for updating an object.

  • DeleteView: View for deleting an object retrieved with self.get_object().

HTTP support: note that you can use POST or PUT HTTP verb for creating/editing an object and POST or DELETE for deleting an object.

Extra views

  • PaginatedListView
  • ProcessFormView
  • ProcessModelFormView
  • DisplayFormView
  • DisplayModelFormView

Date-based views

  • ArchiveView
  • YearView
  • MonthView
  • WeekView
  • DayView
  • TodayView
  • DateDetailView



You can’t perform that action at this time.