user514310
user514310

Reputation:

Heroku - Could not import settings (Django)

I've deleted the settings.py file and create a settings directory at the same level, And created three files. Here are these files.

and put in the init file the following statements.

site_env = get_env_variable('SITE_ENV')
if site_env:
    if site_env == 'staging':
        from .staging import *
    elif site_env == 'production':
        from .production import *

But I am getting error raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)). Am I missing something? Thanks

Upvotes: 1

Views: 768

Answers (1)

user514310
user514310

Reputation:

I've changed the Procfile and create a new common.py file in settings dir. Then I put the following contents in common.py. Now Both servers are running. Thanks :-)

site_env = get_env_variable('SITE_ENV')
if site_env:
    if site_env == 'staging':
        from .staging import *
    elif site_env == 'production':
        from .production import *

Procfile File ->

web: python manage.py runserver --settings=myapp.settings.common 0.0.0.0:$PORT --noreload

Upvotes: 1

Related Questions