﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
8806	ModelAdmin should allow not default manager	Alon Levy	nobody	"My use case is this:

I have a model with two Managers - one named objects (the default), and another one. I want the admin to use the non-default one (in my case I can't even give it the default one since it doesn't return instances of the model, but of another model it inherits from). So my solution (It doesn't even merit a patch - its just 3 lines changed in django/contrib/admin/options.py):

# my code
from django.contrib import admin

class MyAdmin(admin.ModelAdmin):
 model = MyModel
 manager = MyModel.othermanager


# unified diff against django/contrib/admin/options.py svn 8851
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -166,6 +166,8 @@ class ModelAdmin(BaseModelAdmin):
     ordering = None
     inlines = []
 
+    manager = None
+
     # Custom templates (designed to be over-ridden in subclasses)
     change_form_template = None
     change_list_template = None
@@ -239,7 +241,10 @@ class ModelAdmin(BaseModelAdmin):
         Returns a QuerySet of all model instances that can be edited by the
         admin site. This is used by changelist_view.
         """"""
-        qs = self.model._default_manager.get_query_set()
+        if self.manager is None:
+            qs = self.model._default_manager.get_query_set()
+        else:
+            qs = self.manager.get_query_set()
         # TODO: this should be handled by some parameter to the ChangeList.
         ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)
         if ordering:
"		closed	contrib.admin	dev		duplicate	ModelAdmin,Manager	alonlevy1@…	Unreviewed	1	0	0	0	0	0
