Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #469 -- Admin changelist no longer assumes ForeignKey has 'orde…

…ring' set when ordering by a ForeignKey field

git-svn-id: http://code.djangoproject.com/svn/django/trunk@693 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9b68dbf95e10dd9af547176578e0e066aef8bdc5 1 parent 0fa1aa8
Adrian Holovaty authored September 25, 2005

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. 3  django/views/admin/main.py
3  django/views/admin/main.py
@@ -130,7 +130,8 @@ def change_list(request, app_label, module_name):
130 130
     lookup_order_field = order_field
131 131
     if isinstance(lookup_opts.get_field(order_field).rel, meta.ManyToOne):
132 132
         f = lookup_opts.get_field(order_field)
133  
-        lookup_order_field = '%s.%s' % (f.rel.to.db_table, f.rel.to.ordering[0])
  133
+        rel_ordering = f.rel.to.ordering and f.rel.to.ordering[0] or f.rel.to.pk.column
  134
+        lookup_order_field = '%s.%s' % (f.rel.to.db_table, rel_ordering)
134 135
     # Use select_related if one of the list_display options is a field with a
135 136
     # relationship.
136 137
     for field_name in lookup_opts.admin.list_display:

0 notes on commit 9b68dbf

Please sign in to comment.
Something went wrong with that request. Please try again.