Ticket #2895: main.diff

File main.diff, 807 bytes (added by Sergey Kirillov <rushman@…>, 18 years ago)

Updated patch

  • main.py

     
    706706                # For OneToOneFields, don't try to order by the related object's ordering criteria.
    707707                pass
    708708            elif isinstance(f.rel, models.ManyToOneRel):
    709                 rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column
     709                o_field = f.rel.to._meta.ordering[0]
     710                if o_field[0] == '-':
     711                    o_field = o_field[1:]
     712                rel_ordering = f.rel.to._meta.ordering and o_field or f.rel.to._meta.pk.column
    710713                lookup_order_field = '%s.%s' % (f.rel.to._meta.db_table, rel_ordering)
    711714
    712715        # Set ordering.
Back to Top