Bob Fang
Bob Fang

Reputation: 7381

How to set up database properly in django for heroku?

I know this question sounds stupid and I have followed the tutorial heroku provides but everytime I run heroku run python manage.py syncdb it will complain the following:

ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

I did not change setting.DATABASE, I leaved it as it was created by django-admin.py.

How to set the database properly? I have searched around but cannot find an answer.

Thanks.

Upvotes: 0

Views: 116

Answers (2)

EWit
EWit

Reputation: 1994

If you have the add-on enabled you should simply insert:

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

after your initial definition of DATABASES in your settings.py.

Make sure that dj-database-url==0.2.1 is in the requirements.txt

That should be everything to enable it on heroku.

Upvotes: 1

Belug
Belug

Reputation: 71

You shoud use the dj-database-url package https://github.com/kennethreitz/dj-database-url.

and configure your settings like that : Sample project

Upvotes: 1

Related Questions