Ticket #7510: modeladmin_override_manager.diff

File modeladmin_override_manager.diff, 1.8 KB (added by jfw, 16 years ago)
  • django/contrib/admin/options.py

     
    319319        opts = self.opts
    320320        return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())
    321321
     322    def manager(self, request):
     323        """
     324        Returns a Manager to be queried in the admin site. This is used by
     325        queryset, changelist_view, and delete_view.
     326        """
     327        return self.model._default_manager
     328
    322329    def queryset(self, request):
    323330        """
    324331        Returns a QuerySet of all model instances that can be edited by the
    325332        admin site. This is used by changelist_view.
    326333        """
    327         qs = self.model._default_manager.get_query_set()
     334        qs = self.manager(request).get_query_set()
    328335        # TODO: this should be handled by some parameter to the ChangeList.
    329336        ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)
    330337        if ordering:
     
    550557        app_label = opts.app_label
    551558
    552559        try:
    553             obj = model._default_manager.get(pk=object_id)
     560            obj = self.manager(request).get(pk=object_id)
    554561        except model.DoesNotExist:
    555562            # Don't raise Http404 just yet, because we haven't checked
    556563            # permissions yet. We don't want an unauthenticated user to be able
     
    662669        app_label = opts.app_label
    663670
    664671        try:
    665             obj = self.model._default_manager.get(pk=object_id)
     672            obj = self.manager(request).get(pk=object_id)
    666673        except self.model.DoesNotExist:
    667674            # Don't raise Http404 just yet, because we haven't checked
    668675            # permissions yet. We don't want an unauthenticated user to be able
Back to Top