New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async reverse relationship #1142
Comments
try pre fetching also artist_set Card.objects.prefetch_related("cardhold_set", "artist_set") |
Hi @vitalik thanks for your response. I tried that and get the following:
|
yeah, maybe prefetch_related does not support async yet.. try: @api.get("/get-cards", response=List[CardOut])
@decorate_view(cache_page(7 * 24 * 60 * 60))
async def list_cards(request):
queryset = Card.objects.prefetch_related("cardhold_set", "artist_set")
cards = await sync_to_async(list)(queryset) # force executing db query here by converting to list
return cards |
I think you might be right, it doesn't work when I include artist_set, song, or cardhold_set in the schema |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expectation: To be able to run this view async, should this be possible?
Output:
Schema
View
Models
The text was updated successfully, but these errors were encountered: