Admin ChangeList bypasses model's custom manager
|Reported by:||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
When using a custom manager for Model.objects that overrides Manager.get_query_set(), the admin ChangeList disregards it. E.g.:
from django.db import models class MyManager(models.Manager): def get_query_set(self): return super(MyManager, self).get_query_set().filter(mybool=False) class MyModel(models.Model): mybool = models.BooleanField() objects = MyManager()
To reproduce it, add a MyModel object with mybool set to true. The item will appear in the list. While this might be (quite debatably) a good approach, it is inconsistent as trying to edit the object in admin will lead to a 404: object with primary key u'1' does not exist.