Ticket #11695: main.diff
File main.diff, 1.7 KB (added by , 15 years ago) |
---|
-
main.py
63 63 if ERROR_FLAG in self.params: 64 64 del self.params[ERROR_FLAG] 65 65 66 self.order_field, self.order_type = self.get_ordering()66 self.order_field, self.order_type, self.ordering = self.get_ordering() 67 67 self.query = request.GET.get(SEARCH_VAR, '') 68 68 self.query_set = self.get_query_set() 69 69 self.get_results(request) … … 138 138 # manually-specified ordering from the query string. 139 139 ordering = self.model_admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name] 140 140 141 if ordering[0].startswith('-'): 142 order_field, order_type = ordering[0][1:], 'desc' 143 else: 144 order_field, order_type = ordering[0], 'asc' 141 order_field = None 142 order_type = None 145 143 if ORDER_VAR in params: 146 144 try: 147 145 field_name = self.list_display[int(params[ORDER_VAR])] … … 166 164 pass # Invalid ordering specified. Just use the default. 167 165 if ORDER_TYPE_VAR in params and params[ORDER_TYPE_VAR] in ('asc', 'desc'): 168 166 order_type = params[ORDER_TYPE_VAR] 169 return order_field, order_type 167 return order_field, order_type, ordering 170 168 171 169 def get_query_set(self): 172 170 qs = self.root_query_set … … 216 214 # Set ordering. 217 215 if self.order_field: 218 216 qs = qs.order_by('%s%s' % ((self.order_type == 'desc' and '-' or ''), self.order_field)) 217 elif self.ordering: 218 qs = qs.order_by(*self.ordering) 219 219 220 220 # Apply keyword searches. 221 221 def construct_search(field_name):