I have a model A
which contains a generic foreign key relation with limit choices to 3 other models(consider them as B
, C
and D
) in the same app. And I know the limitations of generic foreign keys that we can't use filter
or get
or anyother queryset operations.
So to achieve something like this, A.objects.filter(generic_object__name="foo")
I have to filter B, C and D's objects first as queryset, iterate over them and use the generic reverse relation to get the A
objects as list(not queryset).
I'm not sure about how it'll affect the SQL performace on database as the querying is not direct.
PS: I need to use the generic foreignkeys, so please suggest for any SQL improvement rather than redesigning of models.
Using Django 1.4.3 and Postgres.