Ticket #7510: options.diff
File options.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/options.py
235 235 opts = self.opts 236 236 return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission()) 237 237 238 def manager(self, request): 239 """ 240 Returns a Manager to be queried in the admin site. This is used by 241 queryset, changelist_view, and delete_view. 242 """ 243 if not hasattr(self, 'model_admin_manager'): 244 self.model_admin_manager = self.model._default_manager 245 return self.model_admin_manager 246 238 247 def queryset(self, request): 239 248 """ 240 249 Returns a QuerySet of all model instances that can be edited by the 241 250 admin site. This is used by changelist_view. 242 251 """ 243 qs = self.m odel._default_manager.get_query_set()252 qs = self.manager(request).get_query_set() 244 253 # TODO: this should be handled by some parameter to the ChangeList. 245 254 ordering = self.ordering or () # otherwise we might try to *None, which is bad ;) 246 255 if ordering: … … 554 563 app_label = opts.app_label 555 564 556 565 try: 557 obj = model._default_manager.get(pk=object_id)566 obj = self.manager(request).get(pk=object_id) 558 567 except model.DoesNotExist: 559 568 # Don't raise Http404 just yet, because we haven't checked 560 569 # permissions yet. We don't want an unauthenticated user to be able … … 667 676 app_label = opts.app_label 668 677 669 678 try: 670 obj = self.m odel._default_manager.get(pk=object_id)679 obj = self.manager(request).get(pk=object_id) 671 680 except self.model.DoesNotExist: 672 681 # Don't raise Http404 just yet, because we haven't checked 673 682 # permissions yet. We don't want an unauthenticated user to be able