Ticket #2870: order.patch
File order.patch, 1.4 KB (added by , 18 years ago) |
---|
-
contrib/admin/views/main.py
644 644 # then check the object's default ordering. If neither of those exist, 645 645 # order descending by ID by default. Finally, look for manually-specified 646 646 # ordering from the query string. 647 ordering = lookup_opts.admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name] 647 ordering = lookup_opts.admin.ordering or lookup_opts.ordering or None #['-' + lookup_opts.pk.name] 648 if not ordering: return None, None 648 649 649 650 # Normalize it to new-style ordering. 650 651 ordering = handle_legacy_orderlist(ordering) … … 708 709 elif isinstance(f.rel, models.ManyToOneRel): 709 710 rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column 710 711 lookup_order_field = '%s.%s' % (f.rel.to._meta.db_table, rel_ordering) 712 if lookup_order_field: 713 # Set ordering. 714 qs = qs.order_by((self.order_type == 'desc' and '-' or '') + lookup_order_field) 711 715 712 # Set ordering.713 qs = qs.order_by((self.order_type == 'desc' and '-' or '') + lookup_order_field)714 715 716 # Apply keyword searches. 716 717 def construct_search(field_name): 717 718 if field_name.startswith('^'):