Model Attribute lazy evaluation and async


I was hoping someone could steer me in the right direction regarding attribute lazy evaluation and async. I’m not sure if I’m doing something wrong or missing something?

Say I query a parent model that contains a link to a child model.

parent_model = await ParentModel.objects.afirst()

If I try to access parent_model.child Django tries to go off to the database to pull in the child model. This results in an SynchronousOnlyOperation error. I’m assuming this is because the implicit query that’s executed to fetch the child attribute is being executed as sync

I can force the child to be included in the query by adding “select_related” but that ends up negating the whole point of lazy evaluation.

I can’t find a lot about this in the docs or in general so I’m thinking I’m missing something fundamental?

Typical, the moment you stop looking you find exactly what you need looking for something else…

Add async support for ForwardManyToOne, ForwardOneToOne, and ReverseOneToOne queries - Django Internals / Async - Django Forum (

It looks like it’s intentional and not something that is going to be fixed.

Hey @SteveDev, yes. Lazy evaluations were deliberately decided as something not to add to async. Reasoning was roughly that async is somewhat advanced and the performance implications of lazy fetching are generally thought to outweigh the benefits by that point.