Ticket #7098: 7484-contrib.admin.views.main-fix-order-by.patch
File 7484-contrib.admin.views.main-fix-order-by.patch, 692 bytes (added by , 17 years ago) |
---|
-
django/contrib/admin/views/main.py
diff -r d25f9c768c03 django/contrib/admin/views/main.py
a b 730 730 pass 731 731 elif isinstance(f.rel, models.ManyToOneRel): 732 732 rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column 733 lookup_order_field = '%s .%s' % (f.rel.to._meta.db_table, rel_ordering)733 lookup_order_field = '%s__%s' % (f.name, rel_ordering) 734 734 735 735 # Set ordering. 736 736 qs = qs.order_by((self.order_type == 'desc' and '-' or '') + lookup_order_field)