Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#157 closed defect (fixed)

view/admin/ change_list assumes orderlist is tuple

Reported by: mfenniak@… Owned by: Adrian Holovaty
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:


In the function change_list in views/admin/, 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/
--- django/views/admin/  (revision 293)
+++ django/views/admin/  (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 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

Fixed in [296]. Thanks!

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