From c2a5c49ac279f1e0e2cdbec3de0d957893b9c839 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 22 Jul 2005 18:45:22 +0000 Subject: Fixed #153 -- Changed docs to use new ordering syntax git-svn-id: http://code.djangoproject.com/svn/django/trunk@299 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/tutorial03.txt | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'docs/tutorial03.txt') diff --git a/docs/tutorial03.txt b/docs/tutorial03.txt index eea033fec5..1c547a670f 100644 --- a/docs/tutorial03.txt +++ b/docs/tutorial03.txt @@ -14,25 +14,25 @@ application and will focus on creating the public interface -- "views." A view is a "type" of Web page in your Django application that generally serves a specific function and has a specific template. For example, in a weblog application, you might have the following views: - + * Blog homepage -- displays the latest few entries. * Entry "detail" page -- permalink page for a single entry. - * Year-based archive page -- displays all months with entries in the + * Year-based archive page -- displays all months with entries in the given year. - * Month-based archive page -- displays all days with entries in the + * Month-based archive page -- displays all days with entries in the given month. * Day-based archive page -- displays all entries in the given day. * Comment action -- handles posting comments to a given entry. - + In our poll application, we'll have the following four views: - + * Poll "archive" page -- displays the latest few polls. * Poll "detail" page -- displays a poll question, with no results but with a form to vote. * Poll "results" page -- displays results for a particular poll. * Vote action -- handles voting for a particular choice in a particular poll. - + In Django, each view is represented by a simple Python function. Design your URLs @@ -174,8 +174,7 @@ publication date:: from django.utils.httpwrappers import HttpResponse def index(request): - latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')], - limit=5) + latest_poll_list = polls.get_list(order_by=['-pub_date'], limit=5) output = ', '.join([p.question for p in latest_poll_list]) return HttpResponse(output) @@ -189,8 +188,7 @@ So let's use Django's template system to separate the design from Python:: from django.utils.httpwrappers import HttpResponse def index(request): - latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')], - limit=5) + latest_poll_list = polls.get_list(order_by=['-pub_date'], limit=5) t = template_loader.get_template('polls/index') c = Context(request, { 'latest_poll_list': latest_poll_list, @@ -278,7 +276,7 @@ Two more things to note about 404 views: * The 404 view is also called if Django doesn't find a match after checking every regular expression in the URLconf. - * If you don't define your own 404 view -- and simply use the default, + * If you don't define your own 404 view -- and simply use the default, which is recommended -- you still have one obligation: To create a ``404.html`` template in the root of your template directory. The default 404 view will use that template for all 404 errors. -- cgit v1.3