Ecommerce Demo
The repository includes a full-featured ecommerce demo that exercises every major admin capability. Use it to explore features, test customizations, and as a reference implementation.
Quick start
# From repository root
docker compose -f example/docker-compose.yml up -d
uv sync --group dev
uv run python -m example.ecommerce.seed
uv run python -m example.ecommerce.main
Open in browser:
URL |
Description |
|---|---|
Landing page |
|
Login as admin |
|
Admin index |
|
Product changelist |
|
Custom dashboard view |
Project structure
example/
├── docker-compose.yml
├── templates/admin/ # Template overrides
└── ecommerce/
├── main.py # FastAPI app
├── models.py # 7 Pydantic models
├── admin.py # ModelAdmin classes
├── auth.py # Demo authentication
└── seed.py # Sample data
Registered collections
Collection |
Model |
Highlights |
|---|---|---|
|
Category |
Fieldsets, boolean filter |
|
Brand |
Search, ordering |
|
Product |
Richest model: fieldsets, field mapping, bulk actions, date hierarchy |
|
Customer |
|
|
Order |
Nested line items, date hierarchy, select related |
|
Review |
Approve bulk action, rating filter |
|
Coupon |
Formfield overrides, enum choices |
Features demonstrated
Feature |
Location |
|---|---|
Fieldsets |
Product, Customer, Order change forms |
|
Product price, Customer full name |
List filters |
Status, loyalty tier, payment status |
Date hierarchy |
Product |
|
Product → category/brand; Order → customer |
Field mapping |
|
Bulk actions |
Publish/archive/feature products; approve reviews |
|
Auto-sets |
|
Only admin/manager can delete products |
Custom admin view |
|
Template overrides |
|
i18n + theme |
Header language selector and theme toggle |
Authentication
Demo tokens (development only):
Token |
Role |
Can delete products? |
|---|---|---|
|
admin |
Yes |
|
manager |
Yes |
|
viewer |
No |
Login sets an admin_token cookie via /demo-login?token=admin-token.
API access:
curl -H "Authorization: Bearer admin-token" \
http://localhost:8000/admin/api/products/
Seeding
uv run python -m example.ecommerce.seed
Environment variables:
Variable |
Default |
|---|---|
|
|
|
|
Seeded data: 3 categories, 3 brands, 6 products, 3 customers, 3 orders, 2 reviews, 2 coupons.
Environment variables (app)
Variable |
Default |
Description |
|---|---|---|
|
|
Connection string |
|
|
Database name |
|
|
Uvicorn bind host |
|
|
Uvicorn port |
Customization recipes
The demo source code in example/ecommerce/admin.py is the best reference
for real-world patterns. Key files:
admin.py— allModelAdminconfigurationsmodels.py— rich Pydantic models with enums, nested objects, decimalsauth.py— replace with your production authmain.py—mount_admin_app()wiring
See also example/README.md in the repository for troubleshooting.