- Asynchronous Django (ASGI)
- Celery tasks
- RabbitMQ broker
- Stripe payment system
- Redis Storage
- PostgreSQL database
- Monitoring with Flower
- Docker containers
- Admin panel
- CSV export
- PDF export
- Notifications via email
- Coupon system
- Recommender system
- Create database shop_db with Postgres 16 and new server in PGAdmin:
- Host name/address: localhost
- Port: 5433
- Maintenance database: postgres
- Username: postgres
- Add .env.prod (with Docker Compose) or .env.local (without Docker Compose), and .env.stripe to the project's root.
Generate new Django secret key:
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
-
Create network:
docker network create shop-net
-
Build Docker containers:
docker compose up -d --build
-
To authenticate with Stripe, go to: https://dashboard.stripe.com/stripecli/confirm_auth?t=... (see Docker Desktop logs for full URL)
Remove Docker containers: docker compose down
cd backend
python manage.py collectstatic --noinput --settings=backend.settings.local
cd backend
python -m uvicorn backend.asgi:application --reload
cd backend
# Make new migrations
python manage.py makemigrations --settings=backend.settings.local
# Apply migrations
python manage.py migrate --settings=backend.settings.local
-
Start Docker Desktop.
-
Run commands in terminal:
docker pull rabbitmq
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:management
- RabbitMQ interface is available at http://127.0.0.1:15672
cd backend
python -m celery -A backend worker --pool=solo -l info
# Once:
sudo add-apt-repository universe
sudo apt install redis
sudo service redis-service restart
# Always:
sudo service redis-server start
sudo service redis-server status
# Status: "Ready to accept connections"
redis-cli
Test data:
- Card number: 4242 4242 4242 4242
- Expiration date: 12/29
- CVC: 123
- Country: United States 10001
Links:
Set webhook locally:
- Download stripe_1.19.2_windows_x86_64.zip from GitHub
- Add stripe.exe to your venv/scripts
stripe login --api-key sk_test_...
stripe listen --forward-to localhost:8000/payment/webhook/
# Dump data
cd backend
python -Xutf8 manage.py dumpdata --natural-foreign --exclude=auth.permission --exclude=contenttypes --indent=4 --output=db_data.json --settings=backend.settings.local
# Put db_data.json into backend/fixtures/
# Load data
cd backend
python manage.py loaddata db_data.json --settings=backend.settings.local
Flower: http://localhost:5555/