You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Defining relational fields in a serializer may incur additional database queries, but Django does not natively support asynchronous many-to-one or one-to-one queries. Django will report an error if you try to do many-to-one or one-to-one queries in an async context.
In fact, the best practice is to use select_related or prefetch_related to query all the data that needs to be used at once when defining the queryset, so as to avoid additional database queries in the future.
I want to try to implement a simple asynchronous serializer, but my confusion is that when the user does a many-to-one or one-to-one query and does not use select_related or prefetch_related, should Django report an error or take some way to achieve async many-to-one or one-to-one queries?
I would like to ask what is your take on this matter? Thank you.
The text was updated successfully, but these errors were encountered:
Defining relational fields in a serializer may incur additional database queries, but Django does not natively support asynchronous many-to-one or one-to-one queries. Django will report an error if you try to do many-to-one or one-to-one queries in an async context.
In fact, the best practice is to use select_related or prefetch_related to query all the data that needs to be used at once when defining the queryset, so as to avoid additional database queries in the future.
I want to try to implement a simple asynchronous serializer, but my confusion is that when the user does a many-to-one or one-to-one query and does not use select_related or prefetch_related, should Django report an error or take some way to achieve async many-to-one or one-to-one queries?
I would like to ask what is your take on this matter? Thank you.
The text was updated successfully, but these errors were encountered: