diff --git a/django/views/generic/list_detail.py b/django/views/generic/list_detail.py index 1254eb93dd..7a780d3b1e 100644 --- a/django/views/generic/list_detail.py +++ b/django/views/generic/list_detail.py @@ -6,7 +6,7 @@ from django.core.extensions import DjangoContext as Context from django.core.paginator import ObjectPaginator, InvalidPage from django.core.exceptions import Http404, ObjectDoesNotExist -def object_list(request, app_label, module_name, paginate_by=None, allow_empty=False, +def object_list(request, app_label, module_name, paginate_by=None, allow_empty=False, template_name=None, extra_lookup_kwargs={}, extra_context={}): """ Generic list of objects. @@ -64,28 +64,28 @@ def object_list(request, app_label, module_name, paginate_by=None, allow_empty=F for key, value in extra_context.items(): if callable(value): c[key] = value() - else: + else: c[key] = value if not template_name: template_name = "%s/%s_list" % (app_label, module_name) t = template_loader.get_template(template_name) return HttpResponse(t.render(c)) -def object_detail(request, app_label, module_name, object_id=None, slug=None, - slug_field=None, template_name=None, template_name_field=None, +def object_detail(request, app_label, module_name, object_id=None, slug=None, + slug_field=None, template_name=None, template_name_field=None, extra_lookup_kwargs={}, extra_context={}): """ Generic list of objects. - Templates: ``/_list`` + Templates: ``/_detail`` Context: object - the object (whoa!) + the object """ mod = models.get_module(app_label, module_name) lookup_kwargs = {} if object_id: - lookup_kwargs['%s__exact' % mod.Klass._meta.pk.name] = object_id + lookup_kwargs['pk'] = object_id elif slug and slug_field: lookup_kwargs['%s__exact' % slug_field] = slug else: @@ -108,7 +108,7 @@ def object_detail(request, app_label, module_name, object_id=None, slug=None, for key, value in extra_context.items(): if callable(value): c[key] = value() - else: + else: c[key] = value response = HttpResponse(t.render(c)) populate_xheaders(request, response, app_label, module_name, getattr(object, object._meta.pk.name)) diff --git a/docs/generic_views.txt b/docs/generic_views.txt index e5cbdf60bf..9698719fc9 100644 --- a/docs/generic_views.txt +++ b/docs/generic_views.txt @@ -193,12 +193,13 @@ The date-based generic functions are: Using list/detail generic views =============================== -The list-detail generic views (in the ``django.views.generic.list_detail`` -module) are similar to the data-based ones, except the list-detail views simply -have two views: a list of objects, and an individual object page. +The list-detail generic-view framework (in the +``django.views.generic.list_detail`` module) is similar to the date-based one, +except the former simply has two views: a list of objects and an individual +object page. All these views take the same three optional arguments as the date-based ones -(and they obviously do not accept or require the date field argument). +-- and, clearly, they don't accept the ``date_field`` argument. Individual views are: