Open igormorgado opened 2 years ago
Use select_related
Can you please be more specific. I have read about this keyword in QuerySet
, but didn't help. Also I could not find a single example in https://tortoise-orm.readthedocs.io/en/latest/examples.html that shows how to use it.
Sorry. But do not helped. Thanks.
Describe the bug
Given the model with foreignKey:
Toy --(builder)--> Person
With related name:
Person --(toys_built) --> Toy
Defined with this code:
When resolving the given path
Person --(toys_built)--> Toy --(builder)--> ???
Returns a
QuerySet
instead aPerson
as expected.To Reproduce
Expected behavior
Since the object returned is of type
class Toy
, I would expect to be able to resolvetoy.builder
, exactly like the instancepinocchio.builder
. But for some reason it returns aquerySet
. As we can see, the lastprintf
returns aQuerySet
but I expected aPerson
, as the output shown belowAdditional context
Python 3.9.7 Tortoise 0.17.8