# Configure build and start for Django

## Summary
Configure build and start for a Django app on Ample. Serve project.wsgi with waitress from run.py reading PORT; pass --start "python3 run.py". Static files and collectstatic are not covered. Ample detects the runtime, installs dependencies, runs the build when present and starts the app on the python-3.12 template behind a public HTTPS URL.

## Prerequisites
- A requirements.txt (or pyproject) and a start command that reads PORT and binds 0.0.0.0
- An Ample account token with servers:write

## Workflow Steps
1. **Make the start command bind correctly**  
   Serve project.wsgi with waitress from run.py reading PORT; pass --start "python3 run.py". Static files and collectstatic are not covered.

2. **Deploy**  
   Run the existing synchronous deploy once from the project directory and read the result. Exit 0 is live, 1 is failed, 2 is blocked on a required preflight action. Re-running with no change is a content-addressed no-op.  
   Command: `ample deploy . --name  --public --format json --start "python3 run.py"`

3. **Verify**  
   Fetch the live URL and run the success checks below. On failure read the build log, then the runtime log, fix the cause and deploy again; do not blind-retry.  
   Command: `ample logs  --kind build`

## Example
- **django-postgres canary**: Django 5 project served by waitress with a managed database.  
  Source Reference: `tests/deploy-canaries/django-postgres`

## Success Checks
- **Page or root route responds**  
  - Kind: http_get  
  - Path: /  
  - Expect: ample canary django postgres

## Limitations
- Verified on the node-22 template at s-1vcpu-1gb; other templates and sizes are not verified by this recipe.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- Apps auto-pause when idle and wake on the next request; always-on is an operator setting, not a plan feature.
- ALLOWED_HOSTS must include the Ample hostname (the fixture uses *).
- collectstatic and static file serving are not verified.

## Cost Estimate
- Currency: USD  
- Monthly Amount: 5.0  
- Basis: Size prices from pricing.toml (loaded by the API) at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty  
- Components:  
  - Name: app server  
  - Size: s-1vcpu-1gb  
  - Quantity: 1.0  
  - Monthly Amount: 5.0  
- Note: Apps and managed databases auto-pause when idle; the estimate is the always-on monthly price of the tested sizes. Plan quotas and budgets apply.

## Evidence Summary
- **Canary Run**:  
  - Summary: Django 5 project with dj-database-url and psycopg: the managed PostgreSQL database was auto-provisioned, python3 manage.py migrate ran as the release command, and /db and /migrated reported postgres=ok and the migrated marker.  
  - Observed At: 2026-09-20T01:42:25Z  
  - Implementation Revision: 199ff1dfd52683832ae75d3f98b53a7a4bff7f96-dirty (CLI e3181f5)  
  - Expires At: 2027-03-19T01:42:25Z  
  - Scope:  
    - CLI Version: 0.1.20  
    - Platform: hosted-beta  
    - Template: node-22

## Next Actions
- **Browse the catalog index**
- **Search published recipes by intent, stack and constraints**
- **Prepare a side-effect-free deployment plan for an authorized project**
- **Read the existing agent authentication setup**
- **Browse Django**
- **Browse Configure deployment**
- **Browse Public web service**
