I have the following example:
class Profile(models.Model):
...
class Person(models.Model):
profile = models.ForeignKey(Profile, ...)
I have complex Model manager for Profile class and I built a view to list a big amount of Person. I try to compute everything in database so I would like to call the Profile Manager from Person QuerySet.
To do that, I need to do something like:
Person.objects.filter(...).select_related('profile', queryset=Profile.objects.with_computed_revenue().all())
And then I should be able to get person.profile.computed_revenue retrieved from SQL, with the function "with_computed_revenue" being a function of the ProfileManager that annotate computed_revenue.
The final goal is to add in person queryset :
.values('profile__computed_revenue')
It seems possible with Prefetch for prefetch_related, but I cannot find an equivalent with select_related.