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 trbs, 7 years ago)
  • django/contrib/admin/views/main.py

    diff -r d25f9c768c03 django/contrib/admin/views/main.py
    a b  
    730730                pass
    731731            elif isinstance(f.rel, models.ManyToOneRel):
    732732                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)
    734734
    735735        # Set ordering.
    736736        qs = qs.order_by((self.order_type == 'desc' and '-' or '') + lookup_order_field)
Back to Top