Django

Code

Changeset 128

Show
Ignore:
Timestamp:
07/16/05 18:58:49 (3 years ago)
Author:
adrian
Message:

Changed generic admin changelist to order by ID if no other ordering is specified, rather than raising a scary exception

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/views/admin/main.py

    r116 r128  
    100100        del params[PAGE_VAR] 
    101101    # For ordering, first check the "ordering" parameter in the admin options, 
    102     # then check the object's default ordering. Finally, look for manually- 
    103     # specified ordering from the query string. 
     102    # then check the object's default ordering. If neither of those exist, 
     103    # order descending by ID by default. Finally, look for manually-specified 
     104    # ordering from the query string. 
    104105    if lookup_opts.admin.ordering is not None: 
    105106        order_field, order_type = lookup_opts.admin.ordering 
     107    elif lookup_opts.ordering: 
     108        order_field, order_type = lookup_opts.ordering[0] 
    106109    else: 
    107         order_field, order_type = lookup_opts.ordering[0] 
     110        order_field, order_type = lookup_opts.pk.name, 'DESC' 
    108111    if params.has_key(ORDER_VAR): 
    109112        try: