Deployment · By Rivtor · Updated
Deploy Django REST Framework with a React frontend
Run Django’s API behind a production application server, build React independently and keep PostgreSQL credentials in Django. Configure allowed hosts, browser origins, static files and authentication according to the deployed request path, then test both reads and authorized writes.
See the Rivtor deployment workflow →
Separate static output from the API process
A React build produces frontend assets; Django REST Framework provides API responses. Choose whether they share a public origin through routing or use separate origins. A local React proxy is not the production routing configuration.
Put the Django service’s requirements, manage.py, settings module and migration directories inside its service root. Install a production WSGI or ASGI server matching the application. Keep the frontend’s build manifest and output directory independently usable.
Configure host, origin and credentials deliberately
| Setting boundary | What it controls |
|---|---|
| ALLOWED_HOSTS | Hostnames Django accepts for the request |
| CORS policy | Cross-origin browser access to API responses |
| CSRF policy | Protection for relevant cookie-authenticated writes |
| API permissions | Which user may perform an action on a record |
These controls solve different problems. Allowing a frontend origin does not authorize access to another customer’s data. For session authentication, test a real CSRF-protected write from the deployed frontend. For token authentication, keep token storage and exposure appropriate to the application.
Prepare the production settings
python manage.py check --deploy
Run this illustrative check with the intended production settings selected. Review every warning rather than silencing it. Disable DEBUG, configure the actual public hostname and keep SECRET_KEY and DATABASE_URL out of the React build. Apply reviewed migrations to the selected database and arrange static asset serving; collectstatic alone does not serve files.
Rivtor’s Django and data reference describes supported detection and overrides. If the repository differs from conventional defaults, inspect the service plan and module path before release.
Verify an actual browser journey
Load a frontend route directly, authenticate through the existing application flow and create a disposable record with correct ownership. Confirm an unauthorized account cannot read it. Restart the API and verify persistence. Inspect cookie, redirect and origin behaviour over HTTPS; successful local development does not establish the production browser boundary.