django-ninja-demo
django-ninja-demo copied to clipboard
django-ninja curd demo
Key Features
- 🛡️ High Coverage: Rigorous unit tests for robust codebase assurance.
- 😊 Fast CRUD Router: Quick and easy create, read, update, and delete operations.
- ✅ Uniform API: Consistent responses throughout the service.
- 🔍 Trace IDs: Simplified issue tracking with trace IDs in logs
Quick start
Clone code
git clone https://github.com/lihuacai168/django-ninja-demo.git
Docker-compose
# set env
cp .env.example .env
Make sure db have migrated
# start app
docker-compose -f docker-compose-without-db.yml --env-file=${PWD}/.env up --build
Local Dev
Create virtualenv
python3 -m venv venv
Activate virtualenv
source venv/bin/activate
Install dependencies
cd django-ninja-demo && pip install -r requirements.txt
Migrate db
python manage.py migrate
Start app
python manage.py runserver localhost:8000
Open api docs open in browser
Obtain access token
Authorize and request API
Celery
Config celery broker
# setting.py
broker_url = "redis://127.0.0.1:6379/0"
Run celery worker
# start celery worker, using command line
python -m celery -A apidemo.celery_config worker -l INFO
PyCharm run_celery_worker_configuration
Run celery beat
# start celery beat, using command line
python -m celery -A apidemo.celery_config beat -l DEBUG