Ticket #12875: ticket_12875.diff
File ticket_12875.diff, 2.0 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/options.py
259 259 ) 260 260 return urlpatterns 261 261 262 def get_ordering(self, request): 263 return None 264 262 265 def urls(self): 263 266 return self.get_urls() 264 267 urls = property(urls) -
django/contrib/admin/views/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.get_ordering(request) 67 67 self.query = request.GET.get(SEARCH_VAR, '') 68 68 self.query_set = self.get_query_set() 69 69 self.get_results(request) … … 130 130 self.multi_page = multi_page 131 131 self.paginator = paginator 132 132 133 def get_ordering(self ):133 def get_ordering(self, request): 134 134 lookup_opts, params = self.lookup_opts, self.params 135 # For ordering, first check the "ordering" parameter in the admin 135 # For ordering, first check if exists the "get_ordering" method 136 # in model admin, then check the "ordering" parameter in admin 136 137 # options, then check the object's default ordering. If neither of 137 138 # those exist, order descending by ID by default. Finally, look for 138 139 # manually-specified ordering from the query string. 139 ordering = self.model_admin. ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name]140 ordering = self.model_admin.get_ordering(request) or self.model_admin.ordering or lookup_opts.ordering or ['-' + lookup_opts.pk.name] 140 141 141 142 if ordering[0].startswith('-'): 142 143 order_field, order_type = ordering[0][1:], 'desc'