Thursday, August 12, 2021

Async Help Needed

Does anyone have some links to good guides on getting asnyc to work with Django? I have a use case where I really need to have a view give an async response but I can't get even the most basic of examples working.

I've tried the examples from https://testdriven.io/blog/django-async-views/ with a simple view of:

async def test_view(request):
    return HttpResponse("Hello, async Django!")

I've installed uvicorn and am running it with  uvicorn my_project.asgi:application --reload

My sync views work as expected but the async one just returns an error of "The view sample.views.test_view didn't return an HttpResponse object. It returned an unawaited coroutine instead. You may need to add an 'await' into your view."


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/64f90a01-76fe-4e01-ab3a-a6a0910038c9n%40googlegroups.com.

No comments:

Post a Comment