Locked lesson.
About this lesson
In this lesson, we'll continue to configuring our app for heroku by making more modifications, including: modifying Settings.py, adding Whitenoise Middleware, and creating the Requirements.text file.
Exercise files
Download this lesson’s related exercise files.
Modify Settings.py add Whitenoise Middleware and Create Requirements.text file.docx60.5 KB Modify Settings.py add Whitenoise Middleware and Create Requirements.text file - Solution.docx
58.8 KB
Quick reference
Modify Settings.py add Whitenoise Middleware and Create Requirements.text file
After installing those Heroku-required libraries, we need to add them to our settings.py file.
When to use
Do this anytime you want to host your app on Heroku.
Instructions
After pip installing each of the libraries mentioned, create a requirements.txt file at the terminal:
pip freeze > requirements.txt
Finally, add these lines to your settings.py file:
import django_heroku
import dj_database_url
from decouple import config
MIDDLEWARE = [
'whitenoise.middleware.WhiteNoiseMiddleware',
…
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
django_heroku.settings(locals())
Hints & tips
- pip freeze > requirements.txt
- Change your settings.py file to reflect the new libraries
Lesson notes are only available for subscribers.