A Django polls application ready to deploy on Convox.
This example demonstrates how to deploy a Django application with PostgreSQL on Convox. The polls app showcases database migrations, static file handling, and the Django admin interface - everything you need to get your Django project started.
Deploy to Convox Cloud for a fully-managed platform experience, or to your own Convox Rack for complete control over your infrastructure. Either way, you'll get automatic SSL, load balancing, and zero-downtime deployments out of the box.
-
Create a Cloud Machine at console.convox.com
-
Create the app:
convox cloud apps create django -i your-machine-name- Deploy the app:
convox cloud deploy -a django -i your-machine-name- Run database migrations:
convox cloud run migrate "python manage.py migrate" -a django -i your-machine-name- Load sample data:
convox cloud run web "python manage.py load_sample_data" -a django -i your-machine-name- View your app:
convox cloud services -a django -i your-machine-nameVisit <your-url>/polls/ to see the polls app!
- Create the app:
convox apps create django- Deploy the app:
convox deploy -a django- Run database migrations:
convox run migrate "python manage.py migrate" -a django- Load sample data:
convox run web "python manage.py load_sample_data" -a django- View your app:
convox services -a djangoVisit <your-url>/polls/ to see the polls app!
Cloud:
convox cloud run web "python manage.py createsuperuser" -a django -i your-machine-nameRack:
convox run web "python manage.py createsuperuser" -a djangoGenerate secure key:
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'Cloud:
convox cloud env set SECRET_KEY=<generated-key> -a django -i your-machine-nameRack:
convox env set SECRET_KEY=<generated-key> -a djangopip install -r requirements.txt
export SECRET_KEY='dev-secret-key'
export DATABASE_URL='sqlite:///db.sqlite3'
python manage.py migrate
python manage.py runserver- Django 4.2 with PostgreSQL
- Example polls application
- WhiteNoise for static files
- Gunicorn WSGI server
Cloud:
convox cloud logs -a django -s web -i your-machine-nameRack:
convox logs -a djangoCloud:
convox cloud run web "python manage.py shell" -a django -i your-machine-nameRack:
convox run web "python manage.py shell" -a djangoCloud:
convox cloud resources export database -a django -i your-machine-name --file backup.sqlRack:
convox resources export database -a django --file backup.sql