Fixed typos in generic-views documentation

git-svn-id: http://code.djangoproject.com/svn/django/trunk@434 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-08-08 19:45:57 +00:00
parent a90e9f43db
commit b7e226d8b8
2 changed files with 13 additions and 12 deletions

View File

@ -6,7 +6,7 @@ from django.core.extensions import DjangoContext as Context
from django.core.paginator import ObjectPaginator, InvalidPage from django.core.paginator import ObjectPaginator, InvalidPage
from django.core.exceptions import Http404, ObjectDoesNotExist 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={}): template_name=None, extra_lookup_kwargs={}, extra_context={}):
""" """
Generic list of objects. 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(): for key, value in extra_context.items():
if callable(value): if callable(value):
c[key] = value() c[key] = value()
else: else:
c[key] = value c[key] = value
if not template_name: if not template_name:
template_name = "%s/%s_list" % (app_label, module_name) template_name = "%s/%s_list" % (app_label, module_name)
t = template_loader.get_template(template_name) t = template_loader.get_template(template_name)
return HttpResponse(t.render(c)) return HttpResponse(t.render(c))
def object_detail(request, app_label, module_name, object_id=None, slug=None, def object_detail(request, app_label, module_name, object_id=None, slug=None,
slug_field=None, template_name=None, template_name_field=None, slug_field=None, template_name=None, template_name_field=None,
extra_lookup_kwargs={}, extra_context={}): extra_lookup_kwargs={}, extra_context={}):
""" """
Generic list of objects. Generic list of objects.
Templates: ``<app_label>/<module_name>_list`` Templates: ``<app_label>/<module_name>_detail``
Context: Context:
object object
the object (whoa!) the object
""" """
mod = models.get_module(app_label, module_name) mod = models.get_module(app_label, module_name)
lookup_kwargs = {} lookup_kwargs = {}
if object_id: if object_id:
lookup_kwargs['%s__exact' % mod.Klass._meta.pk.name] = object_id lookup_kwargs['pk'] = object_id
elif slug and slug_field: elif slug and slug_field:
lookup_kwargs['%s__exact' % slug_field] = slug lookup_kwargs['%s__exact' % slug_field] = slug
else: 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(): for key, value in extra_context.items():
if callable(value): if callable(value):
c[key] = value() c[key] = value()
else: else:
c[key] = value c[key] = value
response = HttpResponse(t.render(c)) response = HttpResponse(t.render(c))
populate_xheaders(request, response, app_label, module_name, getattr(object, object._meta.pk.name)) populate_xheaders(request, response, app_label, module_name, getattr(object, object._meta.pk.name))

View File

@ -193,12 +193,13 @@ The date-based generic functions are:
Using list/detail generic views Using list/detail generic views
=============================== ===============================
The list-detail generic views (in the ``django.views.generic.list_detail`` The list-detail generic-view framework (in the
module) are similar to the data-based ones, except the list-detail views simply ``django.views.generic.list_detail`` module) is similar to the date-based one,
have two views: a list of objects, and an individual object page. 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 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: Individual views are: