Ticket #10212: 10212.diff
File 10212.diff, 1.1 KB (added by , 16 years ago) |
---|
-
contrib/admin/views/main.py
131 131 132 132 def get_ordering(self): 133 133 lookup_opts, params = self.lookup_opts, self.params 134 # For ordering, first check the "ordering" parameter in the admin 135 # options, then check the object's default ordering. If neither of 134 # For ordering, first check if `root_query_set` has an order_by clause. 135 # Then check the "ordering" parameter in the admin options, 136 # then check the object's default ordering. If none of 136 137 # those exist, order descending by ID by default. Finally, look for 137 138 # manually-specified ordering from the query string. 138 ordering = self. model_admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name]139 ordering = self.root_query_set.query.order_by or self.model_admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name] 139 140 140 141 if ordering[0].startswith('-'): 141 142 order_field, order_type = ordering[0][1:], 'desc'