Deployment · By Rivtor · Updated
Deploy Django with Postgres
Django needs production settings, a WSGI or ASGI server, a Postgres driver and committed migration history. The development server is not the production entrypoint.
See the Rivtor deployment workflow →
Separate settings from secrets
Read keys and the database URL from environment configuration. Disable DEBUG for production and set ALLOWED_HOSTS to the intended hostname. CSRF trusted origins and cross-origin API permissions are separate controls; configure each for the actual browser workflow.
Prepare assets and dependencies
Install the database driver and server matching the application interface. Decide how static files are collected and served. An API health check can pass while the admin stylesheet is missing, so review assets and application pages as well as the health endpoint.
Review schema changes
Commit migration files, check their dependencies and confirm the target database before running management commands. Create administrative users through an authorized operational workflow rather than embedding credentials in a build script. Recovery planning matters before a destructive migration, not only after it fails.
Check the deployed settings
Run Django’s deployment checks using the production settings. Test login, CSRF handling and one database-backed action with a test account. Check cookie behavior on HTTPS and inspect logs for accidental debugging output. Resolve warnings according to the actual deployment architecture.
Command reference
python manage.py check --deploy
python manage.py collectstatic --noinput
python manage.py migrate
These commands illustrate the documented workflow. Replace example addresses and identifiers with your own. Deployment and migration commands affect the selected project; confirm the target before running them.
Check the production configuration explicitly
Run Django's deployment checks with the same settings module intended for production:
python manage.py check --deploy
python manage.py showmigrations
python manage.py collectstatic --noinput
These checks do not deploy your app. collectstatic writes generated static files; your serving strategy must make those files reachable. Use reviewed dependency versions and a production WSGI or ASGI server. A database URL is not automatically interpreted by Django's DATABASES setting unless your configuration parses it.
Rehearse migrations and browser behavior
Apply reviewed migrations to a disposable Postgres database, then check an authenticated form submission, a persisted record and a static asset. Verify ALLOWED_HOSTS, HTTPS behavior, CSRF_TRUSTED_ORIGINS where applicable, and secure cookie settings against the actual deployed origins.
A CSRF rejection and a CORS preflight failure need different investigations. Do not broadly trust origins merely to make a form succeed. If static assets fail while views work, inspect collection output and serving configuration before changing database settings.
Choose a deployment workflow
Review the detected service root using the CLI reference, and check framework support. Use migration troubleshooting when schema updates fail. Source: Django deployment checklist.
Next steps
Read the Rivtor reference for supported configuration and limitations, and use the deployment quickstart when trying Rivtor for the first time. Validate workflows with synthetic data before connecting valuable production records.