#23055: Filters don't use ModelAdmin get_queryset()
-------------------------------------+-------------------------------------
     Reporter:  ramiro               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  contrib.admin        |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  admin filters        |             Triage Stage:  Accepted
  list_filter multi-db get_queryset  |      Needs documentation:  0
  modeladmin                         |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by synasius):

 Hi ramiro,

 I'm trying to reproduce the issue but I can't. Can you help me?

 This is my current setup: I have a `foo` application with just one `Stuff`
 model

 {{{
 #!python
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3',
         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
     },
     'other': {
         'ENGINE': 'django.db.backends.sqlite3',
         'NAME': os.path.join(BASE_DIR, 'other.sqlite3'),
     },
 }

 DATABASE_ROUTERS = ['help.routers.FooRouter']
 }}}

 and that's my ModelAdmin

 {{{
 #!python
 class MultiDBModelAdmin(admin.ModelAdmin):
     # A handy constant for the name of the alternate database.
     using = 'other'

     def get_queryset(self, request):
         # Tell Django to look for objects on the 'other' database.
         return super(MultiDBModelAdmin,
 self).get_queryset(request).using(self.using)

 # Register your models here.
 class StuffAdmin(MultiDBModelAdmin):
     list_filter = ("empty",)
 }}}

 The router is used to create the `foo_stuff` table only in the `other` db.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23055#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.5303cedf9f2ccfe0b923c4313a221910%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to