A simple Categories API that stores category tree to database and returns category parents, children and siblings by category id.
git clone https://github.com/spanickroon/Categories-API.git
cd Categories-API
touch .env.dev
sudo docker-compose up -d --build
sudo docker ps -a
Links for open api:
http://localhost:8000/categories/
Virtual environment variables for .env.dev file:
DATABASE_ENGINE=django.db.backends.postgresql
DATABASE_HOST=db or localhost(Your data) (use db if you run through docker)
DATABASE_NAME=testdb (Your data)
DATABASE_PASSWORD=test (Your data)
DATABASE_PORT=5432
DATABASE_URL=postgres://test:test@localhost:5432/testdb (Your data)
DATABASE_USER=test (Your data)
SECRET_KEY= (Your data)
ALLOWED_HOSTS=localhost 127.0.0.1 0.0.0.0 [::1] (Your data)
DATABASE=postgres
Use redoc from the link:
http://localhost:8000/redoc/
View logs:
sudo docker-compose logs -f
Use admin panel from the link:
http://localhost:8000/admin/
For removed docer-compose containers use this:
sudo docker-compose down -v
And check:
sudo docker images
For removed images use this:
sudo docker systems pruno
- Django 3.1.5
- Django-rest-framework 3.12.2
- Python3 3.8.5
- PostgreSQL
Successful post request:
Getting a category with id 2:
Getting a category with id 8:
Database records:
Tests: