Ticket #153: order_by_docs.patch

File order_by_docs.patch, 2.0 KB (added by mfenniak@…, 19 years ago)

Patch

  • docs/tutorial03.txt

     
    174174    from django.utils.httpwrappers import HttpResponse
    175175
    176176    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',
    178178            limit=5)
    179179        output = ', '.join([p.question for p in latest_poll_list])
    180180        return HttpResponse(output)
     
    189189    from django.utils.httpwrappers import HttpResponse
    190190
    191191    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',
    193193            limit=5)
    194194        t = template_loader.get_template('polls/index')
    195195        c = Context(request, {
  • docs/db-api.txt

     
    107107    polls.get_list(
    108108        pub_date__year=2005,
    109109        pub_date__month=1,
    110         order_by=(("pub_date", "DESC"), ("question", "ASC")),
     110        order_by=("-pub_date", "question")),
    111111    )
    112112
    113 The result set above will be ordered by ``pub_date`` (descending), then
    114 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.
     113The result set above will be ordered by ``pub_date`` (the negative sign
     114indicates descending ordering), then by ``question`` (ascending).  Just like in
     115models, the ``order_by`` clause is a list of fields to order by.  Each field
     116can be prepended with a negative sign to indicate descending ordering.  You can
     117also use ``?`` as the field to order the result set randomly.
    118118
    119119Relationships (joins)
    120120=====================
Back to Top