Django 中使用协程异步出现的问题
问题
You cannot call this from an async context - use a thread or sync_to_async
原因:
你在异步线路中又去调了同步的线程所以…
解决办法:
from django.contrib.auth.models import User
from asgiref.sync import sync_to_async
import asyncio
@sync_to_async
def get_users():