Django select_related on multitable inheritance -


i'm tring use select_related on multi-table inheritance lookup.
code has drawbacks , wonder if there better solution

class parent(models.model):      user = models.foreignkey(settings.auth_user_model)   class child(models.model):      pass 

with above class definition, i'd serialize parents (heterogeneous)

parents = parent.objects.all().select_related('user', 'child')  parent in parents:     parent.child.user           # <-- db access, nullifies select_related('user')     # i'm passing parent.child childserializer() expects child object, , access user, it's parent.child.user 

i can do

parent.objects.all().selecte_related('child__user') 

but has own problem when there multiple child models (it needs join each child class)


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -