How to solve Server Error (500) when I set Debug - False (Django Heroku )
Here are the steps that worked for me:
step 0:
In your command line, go to your project directory (where manage.py exists)
Step 1:
pip install whitenoise
make sure this library is added to the requirements.txt (
pip freeze > requirements.txt)
Step 2:
go to your settings.py folder and locate MIDDLEWARE. add 'whitenoise.middleware.WhiteNoiseMiddleware',
Step 3:
in the same settings.py add
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
for my case it was just above django_heroku.settings(locals())
Step 4:
now go to your wsgi.py file in the same directory as settings.py type the following at the top from whitenoise import WhiteNoise
also at the bottom you will use the import so add application = WhiteNoise(application)
Step 5:
now change DEBUG = False
and go back to the command prompt in the project directory
Step 6:
type python manage.py collectstatic
after this a new folder will appear in the root directory of your project . Just leave it there
FINAL STEP:
That's it!
Comments
Post a Comment