Django async if else use a thread or sync_to_async
Я не знаю, где находится ошибка
async def receive(self, text_data=None, bytes_data=None):
...
if data['msg']:
print('in')
model = await DB.Myself.filter_data(name__contains='')
print('ok')
else:
print('else')
model = await DB.Myself.filter_data(name__contains='')
print(model, 'model')
Ин, если log
in
ok
In else log
else
You cannot call this from an async context - use a thread or sync_to_async.
Почему?
Вы можете мне помочь?