django-class-based-views 0

A work in progress. Hopefully not too broken. Needs documentation.

Django class-based views

Work on ticket #6735.

Installation

$ python setup.py install

Or for the moment:

$ pip install -e [email protected]:bfirsh/django-class-based-views.git#egg=django-cbv

Usage

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('',
    url(r'^detail/author/(?P<pk>\d+)/$',
        views.AuthorDetail.as_view,
        name="author_detail"),
)

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.

Views

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

API

TODO

Related Repositories

django-vanilla-views

django-vanilla-views

Beautifully simple class-based views. ...

django-extra-views

django-extra-views

Django's class-based generic views are awesome, let's have more of them. ...

django-mailviews

django-mailviews

Class-based email views for the Django framework, including a message previewer. ...

django-password-reset

django-password-reset

Class-based views for password reset ...

django-class-based-views

django-class-based-views

Work on class-based views, now part of Django 1.3. For a backport to Django 1.2, see https://github.com/sorl/django-cbv ...


Top Contributors

bfirsh davidbgk spookylukey