Deploying a Django project on Heroku
1. Modify settings.py
settings.py
1-1. Debug
1-2. SECRET_KEY
2. Install Heroku
Heroku
3. Update the app for Heroku
Heroku
3-1. Procfile
Procfile
same directory as
manage.py
3-2. Install Gunicorn
Gunicorn
The Gunicorn "Green Unicorn" is a Python Web Server Gateway Interface HTTP server.
3-3. Database configuration
dj-database-url (Django database configuration from environment variable)
Add it into the bottom of the
settings.py
psycopg2 (Python Postgres database support)
3-4. Serving static files in production
Install
whitenoise
Add it into the MIDDLEWEAR of the
settings.py
Add it into the bottom of the
settings.py
3-5. Requirements
The Python requirements of your web application must be stored in a file requirements.txt in the root of your repository
3-6. Runtime
runtime.txt
tells Heroku which programming language to use
4. Create and upload the website
4-1. Create the app
4-2. Push our app to the Heroku repository
4-3. Set up the database tables
4-4. Create superuser
4-5. Open your app
5. You are now live
+
Heroku Tips & Tricks
1. Disable collectstatic
To export the data from your Heroku Postgres database, create a new backup and download it.
3. Maintenance Mode
To enable maintenance mode
To disable maintenance mode
To check the current maintenance status of an app
4. Restart
run this when you see this message
"Your account has reached its concurrent builds limit"
5. Loaddata
Last updated