Django - Async Django
You want to run a blocking database query inside an async Django view without blocking the event loop. Which approach is correct?
sync_to_async utility.sync_to_async decorator or function to run the query asynchronously. correctly uses sync_to_async. Call the database query directly inside the async view without changes. blocks event loop. Convert the database query to an async function manually. is not feasible as Django ORM is sync. Run the query in a separate thread without any Django utilities. is risky without Django's helpers.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions