The fastest way to run the bot is to run it in polling mode using SQLite database without all Celery workers for background jobs. This should be enough for quickstart:
git clone https://github.com/ohld/django-telegram-bot
cd django-telegram-botCreate virtual environment (optional)
python3 -m venv dtb_venv
source dtb_venv/bin/activateInstall all requirements:
pip install -r requirements.txt
Create .env file in root directory and copy-paste this or just run cp .env_example .env,
don't forget to change telegram token:
DJANGO_DEBUG=True
DATABASE_URL=sqlite:///db.sqlite3
TELEGRAM_TOKEN=<PASTE YOUR TELEGRAM TOKEN HERE>Run migrations to setup SQLite database:
python manage.py migrateCreate superuser to get access to admin panel:
python manage.py createsuperuserRun bot in polling mode:
python run_polling.py If you want to open Django admin panel which will be located on http://localhost:8000/tgadmin/:
python manage.py runserverIf you want just to run all the things locally, you can use Docker-compose which will start all containers for you.
You can switch to PostgreSQL just by uncommenting it's DATABASE_URL and commenting SQLite variable.
cp .env_example .envTo run all services (Django, Postgres, Redis, Celery) at once:
docker-compose up -d --buildCheck status of the containers.
docker ps -aIt should look similar to this:
Try visit Django-admin panel.
docker exec -it dtb_django bashpython manage.py createsuperuserdocker logs -f dtb_django
