$ DJANGO_SETTINGS_MODULE=ttings telegram_bot.py So, create a separate Python script (for example, telegram_bot.py in the root of your app) for running your Telegram bot and run it separately. All you need to do is to specify DJANGO_SETTINGS_MODULE environment variable to help Django find your settings module. If so, you can still access django from your other scripts. I understand that you're likely seeking for a way to get data from Django ORM inside the Telegram bot or use some other Django features. Different configurations of the web server in different environments will make it harder to write the correct and scalable code for serving both a web app and a Telegram bot. Moreover, now you are using Django Development server using manage.py command, but if you're going to deploy your application to production environment, your configuration will differ: you should use some production-ready solution like gunicorn.
0 Comments
Leave a Reply. |