Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django error in Heroku: "Please supply the ENGINE value"

I read and apply "Getting started with Django on Heroku" tutorial but ran into problem while syncing db:

raise ImproperlyConfigured("settings.DATABASES is improperly configured." 
django.core.exceptions.ImproperlyConfigured: 
settings.DATABASES is improperly configured. Please supply the ENGINE value. 

I read Please supply the ENGINE value Django database configuration and “settings.DATABASES is improperly configured” error performing syncdb with django 1.4 but still receive same error. While executing

heroku run python manage.py --settings=moz455.settings syncdb

I receive error "Unknown command: '--settings=moz455.settings'". How to solve this problem?

Version of Django is 1.4.

like image 305
DSblizzard Avatar asked Aug 06 '12 10:08

DSblizzard


4 Answers

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.

like image 170
sethammons Avatar answered Nov 03 '22 12:11

sethammons


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
like image 29
Or Arbel Avatar answered Nov 03 '22 11:11

Or Arbel


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
like image 3
JohnTESlade Avatar answered Nov 03 '22 12:11

JohnTESlade


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
like image 1
DSblizzard Avatar answered Nov 03 '22 10:11

DSblizzard