Using Django RelatedField for custom join queries?
Hi all,
I've asked this question on stackoverflow (http://stackoverflow.com/questions/18913661/using-django-relatedfield-for-custom-join-queries),
but figured it might be better to post it here:
I'm curious whether a RelatedField can be used to cause custom join queries.
I would like to apply this in django-parler (https://github.com/edoburu/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. Regular field access on instances is covered in django-parler (using descriptors that proxy to calls to the translated table), and I would love to extend support to ORM queries as well.
Best regards,
Diederik
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home