I'm curious whether a RelatedField can be used to cause custom join queries. I would like to apply this in django-parler, a multilingual app for Django.
For example, when "slug" is a translated field, I would like to have:
MyModel.objects.filter(slug="foo")
to operate as:
MyModel.objects.fiter(translations__slug="foo")
under the hood. This is possible with the API of the RelatedField class for example?
I noticed there are several API hooks in the RelatedField
class, such as m2m_reverse_field_name()
, m2m_target_field_name()
, m2m_column_name()
, extra_filters()
etc.. which are used in the GenericRelation
and django-taggit's TaggableManager
classes but I have no idea how these work.
N.B. Field access on instances is covered in django-parler, and I would love to extend that to ORM queries as well.