DjangoPoll is an API for conducting polls. Implemented the ability to register a user, view all polls, the ability to answer questions with the output of the next question depending on the answer to the previous one (Building questions in the form of a tree using the django-mptt library), as well as viewing poll statistics and each question (implemented using pure SQL without Django ORM).
- Python (version 3.12)
- Django (version 5.0)
- DRF (version 3.14)
- django-mptt
- PostgreSQL
- Docker Compose
First, clone project
git clone https://github.com/Niolum/DjangoPoll.git
Further, set up the virtual environment and the main dependencies from the requirements.txt
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Then, create .env file. set environment variables and create database.
Example .env
:
DATABASE_NAME=db_name
DATABASE_USER=username
DATABASE_PASSWORD=password
DATABASE_HOST=localhost
DATABASE_PORT=5432
DEBUG=False
SECRET_KEY='some_secret_key'
Before starting, you need to execute several commands:
python manage.py migrate
Run application:
python manage.py runserver
Open your web browser and navigate to http://localhost:8000/api/v1/docs/ to access your Swagger.
For start in docker-compose create .env_docker:
POSTGRES_USER=username
POSTGRES_PASSWORD=password
POSTGRES_DB=db_name
DATABASE_NAME=db_name
DATABASE_USER=username
DATABASE_PASSWORD=password
DATABASE_HOST='db'
DATABASE_PORT=5431
DEBUG=False
SECRET_KEY='some_secret_key'
To start the project, use the following command:
docker-compose up -d
To run all the tests of a project, simply run the pytest command:
pytest