Work on ticket #6735.
$ python setup.py install
Or for the moment:
$ pip install -e email@example.com:bfirsh/django-class-based-views.git#egg=django-cbv
Inherit your own class-based views from existing ones listed below:
class AuthorDetail(class_based_views.DetailView): queryset = Author.objects.all()
Declare your view in your URLs like you already do for classic views:
import views from django.conf.urls.defaults import * urlpatterns = patterns('', url(r'^detail/author/(?P<pk>\d+)/$', views.AuthorDetail(), name="author_detail"), )
Note: you must declare an instance of the class in your URLs, not the class in order to avoid shared attributes across requests.
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
CreateView: View for creating an object.
UpdateView: View for updating an object.
DeleteView: View for deleting an object retrieved with
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.