This project is a REST API made as a task from Netguru
Firstly you need to have required programs
- Clone/download the repository
- Enter inside project directory on your machine
- Create .env file based on .env-example click here to read more
- Build docker compose, terminal example:
docker-compose build
- Now you can run or test project
To create .env file follow these steps:
- Copy .env-example as .env
- Linux(Debian) terminal example:cp .env-example .env
- Edit .env file
- Linux(Debian) terminal example:nano .env
- Set boolean DJANGO_DEBUG (TRUE or FALSE)
- Set ALLOWED_HOSTS with your IP's or/and sides (if you want to add more than one use comma symbol if you want to allow all use asterisk symbol)
- Additional, non-required in final .env file:
- Add DATABASE_URL as URL to your DB (by default Django will create SQLite DB file after run app)
- Add DJANGO_SECRET_KEY (by default Django will generate random key each time you run the app)
.env file should look like this:
DJANGO_DEBUG=FALSE
ALLOWED_HOSTS=localhost, 0.0.0.0, other_ip, some-side.com, *
DJANGO_SECRET_KEY=your-key-here
DATABASE_URL=your-db_url-here
Back to setup
Back to overview
Firstly setup project
To run the project using this command:docker-compose up
Back to setup
Back to overview
Firstly setup project
To run tests use this command:docker-compose run app bash -c "python manage.py test"
If the command above doesn't work use this instead:docker-compose run app bash -c "python manage.py test api"
Back to setup
Back to overview
Technologies:
- Docker
- Docker Compose
- python 3.8.5
- PostgreSQL - I choose this SQL DB because it's more professional than SQLite which I often use in my projects
Python frameworks & libraries:
- django - the framework for web apps (I did not learn other web apps frameworks for python like Flask because I think Django is the most community supported and brilliant for big project usage)
- django rest framework - the framework for REST API's compatible with Django, is must have for REST API projects because of features that are provided for the developer's usage
- drf-yasg - easy to use docs generator for Django REST framework, also must have for REST API project in my opinion, because that provides us easy to read and use for humans docs like swagger or redoc
- requests - used to validate data by requesting cars from used vehicle API
- django-environ, python-decouple, dj_database_url - for statics files and reading .env file values
- psycopg2 - required PostgreSQL library