diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-07-16 23:58:49 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-07-16 23:58:49 +0000 |
| commit | 82f04688014ff309e1744d76f0cc09ad69fc8db8 (patch) | |
| tree | b43ff38a582ad57c9b7cfdc302ef42951bdcdd1d | |
| parent | cfcf3ca1e3fc116388e9f95064acc0cf2233a93f (diff) | |
Changed generic admin changelist to order by ID if no other ordering is specified, rather than raising a scary exception
git-svn-id: http://code.djangoproject.com/svn/django/trunk@128 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/views/admin/main.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/views/admin/main.py b/django/views/admin/main.py index 34c8d1cd83..5b06db0ae5 100644 --- a/django/views/admin/main.py +++ b/django/views/admin/main.py @@ -99,12 +99,15 @@ def change_list(request, app_label, module_name): if params.has_key(PAGE_VAR): del params[PAGE_VAR] # For ordering, first check the "ordering" parameter in the admin options, - # then check the object's default ordering. Finally, look for manually- - # specified ordering from the query string. + # then check the object's default ordering. If neither of those exist, + # order descending by ID by default. Finally, look for manually-specified + # ordering from the query string. if lookup_opts.admin.ordering is not None: order_field, order_type = lookup_opts.admin.ordering - else: + elif lookup_opts.ordering: order_field, order_type = lookup_opts.ordering[0] + else: + order_field, order_type = lookup_opts.pk.name, 'DESC' if params.has_key(ORDER_VAR): try: order_key = int(params[ORDER_VAR]) |
