Prerequisites
- Python 3.12+
- PostgreSQL 15+ (Docker recommended)
- Redis (optional for local dev; recommended for Celery and caching in production)
- Git
Step-by-step installation
Step 1: Clone the repository
Step 2: PostgreSQL (Docker)
Step 3: Virtual environment and dependencies
Step 4: Environment variables
Copy the example env file and edit as needed:ENVIRONMENT so the app uses .env.dev (e.g. leave default or set ENVIRONMENT=development). Ensure DATABASE_URL matches your PostgreSQL setup, for example:
postgres://devuser:devpass@localhost:5432/devdb
| Variable | Purpose |
|---|---|
SECRET_KEY | Django secret (required) |
DEBUG | Set to True in dev |
ALLOWED_HOSTS | Comma-separated hosts |
REDIS_URL | Optional; used for cache and Celery |
CACHE_BACKEND | redis or dummy (dev) |
Step 5: Migrations (django-tenants)
Run shared (public) migrations first, then tenant schemas:Step 6: Create a tenant (school)
The app uses django-tenants: each school is a Client with a Domain. You can:- Create a tenant via Django admin (after creating a superuser with
python manage.py createsuperuser), or - Use the system API once the first platform user exists:
POST /api/v1/system/schools/(and add a Domain), or - Use any custom management command your project provides (e.g.
create_tenantif present).
localhost or school1.localhost) so requests resolve to the correct schema.
Step 7: Run the server
- API:
http://localhost:8000 - Swagger UI:
http://localhost:8000/api/docs/ - ReDoc:
http://localhost:8000/api/redoc/ - Admin:
http://localhost:8000/admin/(aftercreatesuperuser)
For school endpoints, send requests to the tenant domain (e.g. the host you configured for that Client). For system endpoints, use the main/public domain. You can also use the
X-Schema-Name header (superadmin) to target a schema without subdomains.Optional: Celery and Redis
For chatbot background tasks and report generation:- Start Redis (e.g.
docker run -d -p 6379:6379 redis:7). - Set
REDIS_URLandCACHE_BACKEND=redisin.env.dev. - Run a worker:
celery -A sms worker -l info(and optionally beat for scheduled tasks).