Skip to content

Conversation

qodot
Copy link

@qodot qodot commented Sep 8, 2024

When applying the paginate decorator to an async view that returns a Django queryset, a SynchronousOnlyOperation error occurs. (cause of

async def evaluate(results: Union[List, QuerySet]) -> AsyncGenerator:
for result in results:
yield result
)

To resolve this, I've added _inject_async_pagination within the paginate and RouterPaginated and differentiated the behavior based on the view type.

@qodot qodot changed the title Fix SynchronousOnlyOperation error when paginate is used with async views returning Django querysets. Fix SynchronousOnlyOperation error if @paginate with async view returns Django queryset Sep 9, 2024
)

async def evaluate(results: Union[List, QuerySet]) -> AsyncGenerator:
for result in results:
Copy link

@michalasia10 michalasia10 Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be fixed by just adding async to this for loop.

Anyway, bump beacuse I had also this issue ;d

@vitalik pls check this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants