Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#157 closed defect (fixed)

view/admin/main.py change_list assumes orderlist is tuple

Reported by: mfenniak@… Owned by: adrian
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In the function change_list in views/admin/main.py, an assumption is made that the "ordering" variable will be a tuple. The orderlist can be a single string, according to the behaviour built in meta.handle_legacy_orderlist. As a result of this, the code around line 106 seems incorrect, as it assumes an indexable array. Since a string actually is an indexable array, no error is thrown immediately.

The following patch restores my admin pages to working order, but it may not be the best way to handle this.

Index: django/views/admin/main.py
===================================================================
--- django/views/admin/main.py  (revision 293)
+++ django/views/admin/main.py  (working copy)
@@ -98,6 +98,9 @@
 
     # Normalize it to new-style ordering.
     ordering = meta.handle_legacy_orderlist(ordering)
+    if isinstance(ordering, basestring):
+        # tupelize it
+        ordering = (ordering,)
 
     if ordering[0].startswith('-'):
         order_field, order_type = ordering[0][1:], 'DESC'

Change History (1)

comment:1 Changed 10 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [296]. Thanks!

Note: See TracTickets for help on using tickets.
Back to Top