I am trying to make the Django tutorial codes polls into async with uvicorn async view. ORM query works with async view by wrapping in sync_to_async() as such.
question = await sync_to_async(Question.objects.get, thread_sensitive=True)(pk=question_id)
But I have no idea how to apply sync_to_async or thread inside Django templates.
This code fails saying 'You cannot call this from an async context - use a thread or sync_to_async.' Or any other way to work around this?
{% for choice in question.choice_set.all %}
I use Python 3.10, Django 4.0.4 and uvicorn 0.17.6