Ticket #153: order_by_docs.patch
File order_by_docs.patch, 2.0 KB (added by , 19 years ago) |
---|
-
docs/tutorial03.txt
174 174 from django.utils.httpwrappers import HttpResponse 175 175 176 176 def index(request): 177 latest_poll_list = polls.get_list(order_by= [('pub_date', 'DESC')],177 latest_poll_list = polls.get_list(order_by='-pub_date', 178 178 limit=5) 179 179 output = ', '.join([p.question for p in latest_poll_list]) 180 180 return HttpResponse(output) … … 189 189 from django.utils.httpwrappers import HttpResponse 190 190 191 191 def index(request): 192 latest_poll_list = polls.get_list(order_by= [('pub_date', 'DESC')],192 latest_poll_list = polls.get_list(order_by='-pub_date', 193 193 limit=5) 194 194 t = template_loader.get_template('polls/index') 195 195 c = Context(request, { -
docs/db-api.txt
107 107 polls.get_list( 108 108 pub_date__year=2005, 109 109 pub_date__month=1, 110 order_by=( ("pub_date", "DESC"), ("question", "ASC")),110 order_by=("-pub_date", "question")), 111 111 ) 112 112 113 The result set above will be ordered by ``pub_date`` ( descending), then114 by ``question`` (ascending). Just like in models, the ``order_by`` clause 115 is a list of ordering tuples where the first element is the field and the 116 second is "ASC" (ascending) or "DESC" (descending). You can also 117 use the tuple ``(None, "RANDOM")``to order the result set randomly.113 The result set above will be ordered by ``pub_date`` (the negative sign 114 indicates descending ordering), then by ``question`` (ascending). Just like in 115 models, the ``order_by`` clause is a list of fields to order by. Each field 116 can be prepended with a negative sign to indicate descending ordering. You can 117 also use ``?`` as the field to order the result set randomly. 118 118 119 119 Relationships (joins) 120 120 =====================