Django

Code

Changeset 299

Show
Ignore:
Timestamp:
07/22/05 13:45:22 (3 years ago)
Author:
adrian
Message:

Fixed #153 -- Changed docs to use new ordering syntax

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/db-api.txt

    r212 r299  
    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`` descending, then 
     114by ``question`` ascending. The negative sign in front of "-pub_date" indicates 
     115descending order. Ascending order is implied. To order randomly, use "?", like 
     116so:: 
     117 
     118    polls.get_list(order_by=['?']) 
    118119 
    119120Relationships (joins) 
  • django/trunk/docs/model-api.txt

    r283 r299  
    7777    The default ordering for the object, for use by ``get_list`` and the admin:: 
    7878 
    79         ordering = (('order_date', 'DESC'),) 
    80  
    81     This is a tuple of 2-tuples. Each 2-tuple is ``(field_name, ordering_type)`` 
    82     where ordering_type is either ``"ASC"`` or ``"DESC"``.  You can also use the 
    83     ``(None, "RANDOM")`` for random ordering
     79        ordering = ['-order_date'] 
     80 
     81    This is a tuple or list of strings. Each string is a field name with an 
     82    optional "-" (indicating descending order). Or, you can use the string "?" 
     83    to order randomly
    8484 
    8585``permissions`` 
     
    663663 
    664664``ordering`` 
    665     An ordering tuple (see the `Options for models`_, above) that gives a 
     665    A list or tuple (see the `Options for models`_, above) that gives a 
    666666    different ordering for the admin change list. If this isn't given, the 
    667667    model's default ordering will be used. 
  • django/trunk/docs/tutorial03.txt

    r280 r299  
    1515    serves a specific function and has a specific template. For example, in a 
    1616    weblog application, you might have the following views: 
    17      
     17 
    1818        * Blog homepage -- displays the latest few entries. 
    1919        * Entry "detail" page -- permalink page for a single entry. 
    20         * Year-based archive page -- displays all months with entries in the  
     20        * Year-based archive page -- displays all months with entries in the 
    2121          given year. 
    22         * Month-based archive page -- displays all days with entries in the  
     22        * Month-based archive page -- displays all days with entries in the 
    2323          given month. 
    2424        * Day-based archive page -- displays all entries in the given day. 
    2525        * Comment action -- handles posting comments to a given entry. 
    26      
     26 
    2727    In our poll application, we'll have the following four views: 
    28      
     28 
    2929        * Poll "archive" page -- displays the latest few polls. 
    3030        * Poll "detail" page -- displays a poll question, with no results but 
     
    3333        * Vote action -- handles voting for a particular choice in a particular 
    3434          poll. 
    35      
     35 
    3636    In Django, each view is represented by a simple Python function. 
    3737 
     
    175175 
    176176    def index(request): 
    177         latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')], 
    178             limit=5) 
     177        latest_poll_list = polls.get_list(order_by=['-pub_date'], limit=5) 
    179178        output = ', '.join([p.question for p in latest_poll_list]) 
    180179        return HttpResponse(output) 
     
    190189 
    191190    def index(request): 
    192         latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')], 
    193             limit=5) 
     191        latest_poll_list = polls.get_list(order_by=['-pub_date'], limit=5) 
    194192        t = template_loader.get_template('polls/index') 
    195193        c = Context(request, { 
     
    279277    * The 404 view is also called if Django doesn't find a match after checking 
    280278      every regular expression in the URLconf. 
    281     * If you don't define your own 404 view -- and simply use the default,  
     279    * If you don't define your own 404 view -- and simply use the default, 
    282280      which is recommended -- you still have one obligation: To create a 
    283281      ``404.html`` template in the root of your template directory. The default