I read and apply \"Getting started with Django on Heroku\" tutorial but ran into problem while syncing db:
raise ImproperlyConfigured(\"settings.DATABASES is
After trying all the answers here and verifying DATABASE_URL exists, nothing worked.
I added the second line and it worked
DATABASES['default'] = dj_database_url.config() <--- heroko docs says this is enough
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' <---- add this
it is a little late ; but you just delete all default django database settings lines ; and add heroku's one.
it will work correctly
** edit ** or simply you can use `socket.gethostname().
example :
if socket.gethostname() == 'xx':
DATABASE_SETTINGS ={ }
elif socket.gethostname() == 'xxx':
another database settings...
so you can run your project under multiple hosts.
Try different order:
heroku run python manage.py syncdb --settings=moz455.settings
The manage.py command looks like this:
manage.py <command> <options>
but you used it like this:
manage.py <options> <command>
Your other problem (lack of ENGINE setting) may be caused by incorrect settings file being used during the syncdb command execution. The above should fix it also.
Solved it myself: in manage.py add code similar to this:
CurDir = os.path.dirname(os.path.abspath(__file__))
ProjectDir = os.path.join(CurDir, "moz455")
sys.path += [ProjectDir]
And commit changes with these commands:
git add -A
git commit -m "commit"
git push -f heroku
I ran into the same issue, but apparently for different reasons. In the Heroku docs at https://devcenter.heroku.com/articles/django#prerequisites, it says to add the following to settings.py
:
DATABASES['default'] = dj_database_url.config()
You can pass in a parameter of:
DATABASES['default'] = dj_database_url.config(default='postgres://user:pass@localhost/dbname')
And that will allow you to develop locally and on Heroku. The part that actually SOLVES the problem I had though was that the Heroku config environment variable of DATABASE_URL was not actually set. To set this, I ran
$ heroku config
I saw the Database URL assigned to a separate config variable. So I created a new variable:
$ heroko config:add DATABASE_URL={#the database url}
That solved my problem. I hope it helps anyone else with similar issues.
Ensure that you have the database add-on installed and setup properly. See https://devcenter.heroku.com/articles/database#no-dev-database-or-no-database-url
I ran the following to fix the issue:
heroku addons:add heroku-postgresql
heroku pg:promote HEROKU_POSTGRESQL_CYAN