1👍
For a simple case, you would just do:
Manufacturer.objects.filter(company__name='Davies')
If you want to define a custom filter, it looks like the best way to do this is to set a custom manager on your model as described here: https://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers
I have not actually done this, but if you define a manager for your model, you should be able to do one of the following:
- Override the
filter
method, then you should be able to modifykwargs
as necessary to replace your aliases with your long ugly join - Define a new method like
my_filter
that applies the filtering you want
A related SO question: Django Custom Queryset filters
Source:stackexchange.com