Open alifanov opened 4 years ago
When I use default session engine (sqlite) it's ok
In [13]: client = TelegramClient(
...: 'test',
...: api_id,
...: api_hash
...: )
In [14]: client.connect()
at django 2.2.7 still work, django 3+ - dont
Any updates to Django 3+? Someone found a workaround or can share a repository where Django and Telethon have been integrated sucessfully?
Any updates to Django 3+? Someone found a workaround or can share a repository where Django and Telethon have been integrated sucessfully?
Hello , I have made it work on django 3+, what you need to do is to use asyncio and run telethon as async function
Snippet:
async def search_telegram(query,date = None):
async with TelegramClient('SESSION NAME', api_id, api_hash) as client:
#dialogs = await client.get_dialogs()
result = await client(functions.messages.SearchGlobalRequest(
q=query,
filter=types.InputMessagesFilterEmpty(),
min_date=date,
max_date=None,
offset_rate=0,
offset_peer='media',
offset_id=0,
limit=100000000,
folder_id=0
))
return result
For Django View
from asyncio import run
def view_name(request):
telegram_hits = run(search_telegram(iptv_dns))
print(telegram_hits)
I get an exception when I try to use DjangoSession django version is 3.1