DjangoGirls / tutorial-extensions

Additional tasks for tutorial
https://tutorial-extensions.djangogirls.org
Other
162 stars 202 forks source link

settings.py error in "Deploy your website on Heroku" section #86

Closed TetsuFe closed 6 years ago

TetsuFe commented 6 years ago

mysite/settings.py

import dj_database_url
DATABASES['default'] = dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = ['*']

DEBUG = False

try:
    from .local_settings import *
except ImportError:
    pass

I tried to deploy on heroku with above code, I got this error.

$ heroku logs
(omitted)
2017-07-21T18:55:02.766691+00:00 app[web.1]:   File "/app/register/settings.py", line 92, in <module>
2017-07-21T18:55:02.766691+00:00 app[web.1]:     DATABASES['default'] = dj_database_url.config()
2017-07-21T18:55:02.766694+00:00 app[web.1]: NameError: name 'DATABASES' is not defined
(omitted)

So I rewrite to below: mysite/settings.py

try:
    from .local_settings import *
except ImportError:
    pass
import dj_database_url
DATABASES['default'] = dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = ['*']

DEBUG = False

this code passed. No error occurred. So I think you need to fix code "settings.py" in "Deploy your website on Heroku. Do you any other opinion? Because I'm beginner.

TetsuFe commented 6 years ago

Sorry, I skipped to read "add the following lines at the end of the file"