Skip to content

xiidot1303/avtotest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Demo

A demo project using Django, including Telegram bot integration with options to run via webhook or polling.

Table of Contents

Installation

Server Installation

  1. Run the installation script:
    bash install.sh

Development Installation

  1. 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
    
  2. Create a virtual environment:

    python3.10 -m venv venv
  3. Activate the virtual environment:

    • On Linux:
      source venv/bin/activate
    • On Windows:
      venv\Scripts�ctivate
  4. Install dependencies:

    pip install -r requirements.txt
  5. 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
  6. Create a superuser for Django admin:

    python manage.py createsuperuser

Usage

Starting the Project

  • Using Webhook (Recommended for production):

    1. Set the WEBHOOK_URL in your .env file.
    2. Run the following command to set the webhook:
      python manage.py set_webhook
    3. Start the server using Uvicorn:
      python manage.py run_uvicorn
  • Without Webhook (Using Polling):

    1. Start the Django development server:
      python manage.py runserver
    2. Run the Telegram bot in polling mode:
      python manage.py run_polling

Features

  • Django-based web application
  • Telegram bot integration with webhook and polling support
  • Admin panel for managing application data

Configuration

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.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/your-feature-name)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/your-feature-name)
  5. Open a Pull Request

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

Shahzod - [email protected]

Project Link: https://github.com/Venons-ltd/django-demo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published