DEBUG = False breaks templates

I can load /admin locally & on heroku, but the template directory doesn't seem to load properly once I have DEBUG = False.

Switching it to True in settings/local.py properly renders the admin templates locally.

Does this have something to do with Django 1.5's requirement for ALLOWED_HOSTS? I currently have it set to ALLOWED_HOSTS = ['*']

Any help would be apprecaited

Sorry You must be a logged in, registered user to answer a question.

Answers

I ran into the same error and it has to do with the way Django serves static files. In DEBUG=True mode, Django serves the static files for you but turns it off when DEBUG=False.

To fix this, I changed the Procfile so Heroku runs the command collectstatic and runserver with the --insecure flag:

web: python manage.py collectstatic --noinput; python manage.py runserver 0.0.0.0:$PORT --noreload --insecure

On your local machine, you can do $ python manage.py runserver --insecure

Now when DEBUG=False, it will still serve your static files.

Hmm, adding the --insecure flag when I run locally while DEBUG = False doesn't fix my problem.
yelnatz on
web: python manage.py runserver 0.0.0.0:$PORT --noreload --insecure
jinzhang273 on
Just an update, after playing around with another project, it seems you just need to add the --insecure flag to fix this.
jinzhang273 on
Just an update, after playing around with another project, it seems you just need to add the --insecure flag to fix this.
jinzhang273 on