A demo project using Django, including Telegram bot integration with options to run via webhook or polling.
- Run the installation script:
bash install.sh
-
Set up environment variables:
cp conf/env .env
Edit the
.env
file with your settings. Example:PORT=8000 SECRET_KEY=O6xUnFBeYFhlBn_Bpwy0jmuZjcrtiNy_gGmS19yUuw6hi18xIQzw4-dJvzgMJcbKHm8 ALLOWED_HOSTS=* CSRF_TRUSTED_ORIGINS=http://127.0.0.1:8000 DEBUG=True BOT_API_TOKEN=[Your bot token here] WEBHOOK_URL=[ngrok url] | if you use webhook
-
Create a virtual environment:
python3.10 -m venv venv
-
Activate the virtual environment:
- On Linux:
source venv/bin/activate
- On Windows:
venv\Scripts�ctivate
- On Linux:
-
Install dependencies:
pip install -r requirements.txt
-
Apply database migrations:
python manage.py migrate python manage.py makemigrations app python manage.py makemigrations bot python manage.py migrate app python manage.py migrate bot
-
Create a superuser for Django admin:
python manage.py createsuperuser
-
Using Webhook (Recommended for production):
- Set the
WEBHOOK_URL
in your.env
file. - Run the following command to set the webhook:
python manage.py set_webhook
- Start the server using Uvicorn:
python manage.py run_uvicorn
- Set the
-
Without Webhook (Using Polling):
- Start the Django development server:
python manage.py runserver
- Run the Telegram bot in polling mode:
python manage.py run_polling
- Start the Django development server:
- Django-based web application
- Telegram bot integration with webhook and polling support
- Admin panel for managing application data
Refer to the .env
file for configuration options. Make sure to set your bot's API token and the webhook URL if you plan to use webhook mode.
- Fork the repository
- Create your feature branch (
git checkout -b feature/your-feature-name
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature-name
) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for more details.
Shahzod - [email protected]
Project Link: https://github.com/Venons-ltd/django-demo