Take the 2-minute tour ×

I was reading some tutorials and books about generic views.

In part 4 of the official tutorial, they wrote an example like this

from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from polls.models import Poll

urlpatterns = patterns('',

I have also been reading The Definitive Guide to Django: Web Development Done Right, Second Edition and when they talked about generic views, they wrote their example like this

from django.conf.urls.defaults import *
from django.views.generic import list_detail
from mysite.books.models import Publisher

publisher_info = {
    'queryset': Publisher.objects.all(),
    'template_name': 'publisher_list_page.html',

urlpatterns = patterns('',
    (r'^publishers/$', list_detail.object_list, publisher_info)

Should I be using ListView or list_detail? They both come from django.views.generic. If they can both be used, then what's the difference (advantage and disadvantage comparison)?

In case it helps, I'll explain my objective: In my project, I want to list work orders, and then I want a detailed view of each work order that will also contain a list of comments for that order (similar to comments per blog post).

share|improve this question

2 Answers 2

up vote 8 down vote accepted

ListView (class-based) is intended to replace object_list (function-based) because there is limited flexibility to extending a function's behavior.

As the Django documentation notes, the function-based generic views are deprecated in favor of the class-based versions. So try to use ListView, since Django may be removed object_list.

Either way, I prefer to put all the customizations in views.py to avoid cluttering up urls.py, which tends to be a dumping ground of things.

share|improve this answer
I don't really understand the Class based generic view documentation. For example, for ListView, why is the entry so short? Where can I find the list of all the methods and variables? –  hobbes3 Mar 23 '12 at 5:47
Unfortunately, it's part of bad documentation on Django's part (partially because of the multiple inheritance). But you can view what they subclass: e.g. - docs.djangoproject.com/en/dev/ref/class-based-views/… –  Jeff Mar 23 '12 at 6:46

I'm finding Classy useful as an easy way to view an outline of each CBV: http://ccbv.co.uk/projects/Django/1.6/django.views.generic.list/ListView/

It feels like a missing part of the Django docs now.

share|improve this answer
This isn't the accepted answer, but this resource is amazing. –  edhedges Dec 6 '12 at 2:40
Unfortunately, the link appears broken :( –  moooeeeep Mar 19 at 13:05
Just checked it and the URL still works for me -- I use it most days. Edited the comment to include Dj 1.6. –  trojjer Mar 20 at 11:47

Your Answer


