I don't know what I did wrong
I can't get Database Data.
class AsyncChatConsumer(AsyncWebsocketConsumer):
async def receive(self, text_data):
users = await self.get_users()
for user in users:
print(user.id)
@database_sync_to_async
def get_users(self):
return User.objects.all()
django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.
The information I checked and the official documents are all written in this way.
But why am I getting an error?