I want to use Telethon from the django. But when I am running it, I am getting following error:
RuntimeError: There is no current event loop in thread 'Thread-1'.
my code views.py:
from django.shortcuts import render,HttpResponse from telethon.sync import TelegramClient, events async def join(client): ch = '@andeh_ir' try: await client(JoinChannelRequest(ch)) print('[+] Joined The Channel') except: print('[-] skiped') def addChannel(request): api_id = XXXXXX api_hash = 'xxxxxxxxxxxxxxxxxxxxx' client = TelegramClient('+254716550762', api_id, api_hash ) with client: client.loop.run_until_complete(join(client)) return HttpResponse('addChannel')