How to use custom managers in reverse relations?

2.5k Views Asked by At

I want to get the related object references and I want to use a custom manager.

I see there has been already a question about it, but its not open anymore. So im creating a new one Edit: And its outdated.

This is pretty much what im trying to do: Related objects reference with custom manager

b.entry_set.all() # This will use the default Manager
b.custom_manager.entry_set.all() # This should use my custom model manager

I see the ticket is closed but i havent found a solution to it yet. https://code.djangoproject.com/ticket/3871

Im using django 1.6.5

2

There are 2 best solutions below

5
On BEST ANSWER

I have found only this solution:

instance.entry_set(manager='custom_manager')
0
On

In Django 1.8, you can override the _default_manager attribute, which is used for reverse relationships (and direct queries via objects).