diff options
| author | Christopher Long <indirecthit@gmail.com> | 2006-07-27 22:38:02 +0000 |
|---|---|---|
| committer | Christopher Long <indirecthit@gmail.com> | 2006-07-27 22:38:02 +0000 |
| commit | 75c6dc967d4f27a8361d8cf77a1ea279ba9fa3b1 (patch) | |
| tree | 2b1ad1b7c7af7cc9ed04a843c33d6ae539b51475 /docs/tutorial03.txt | |
| parent | 8e48efbbd09685f04856bf448d37c4b7a84e8548 (diff) | |
[per-object-permissions] Update to trunk
git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@3464 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/tutorial03.txt')
| -rw-r--r-- | docs/tutorial03.txt | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/tutorial03.txt b/docs/tutorial03.txt index 3a830eb76f..248d234043 100644 --- a/docs/tutorial03.txt +++ b/docs/tutorial03.txt @@ -189,7 +189,7 @@ publication date:: from django.http import HttpResponse def index(request): - latest_poll_list = Poll.objects.all().order_by('-pub_date') + latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] output = ', '.join([p.question for p in latest_poll_list]) return HttpResponse(output) @@ -202,7 +202,7 @@ So let's use Django's template system to separate the design from Python:: from django.http import HttpResponse def index(request): - latest_poll_list = Poll.objects.all().order_by('-pub_date') + latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] t = loader.get_template('polls/index.html') c = Context({ 'latest_poll_list': latest_poll_list, @@ -288,7 +288,7 @@ exception if a poll with the requested ID doesn't exist. A shortcut: get_object_or_404() ------------------------------- -It's a very common idiom to use ``get_object()`` and raise ``Http404`` if the +It's a very common idiom to use ``get()`` and raise ``Http404`` if the object doesn't exist. Django provides a shortcut. Here's the ``detail()`` view, rewritten:: @@ -313,8 +313,8 @@ exist. foremost design goals of Django is to maintain loose coupling. There's also a ``get_list_or_404()`` function, which works just as -``get_object_or_404()`` -- except using ``get_list()`` instead of -``get_object()``. It raises ``Http404`` if the list is empty. +``get_object_or_404()`` -- except using ``filter()`` instead of +``get()``. It raises ``Http404`` if the list is empty. Write a 404 (page not found) view ================================= |
