Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm setting up a Django app on Heroku using the https://devcenter.heroku.com/articles/django tutorial and I'm running into the below error running heroku run python manage.py syncdb

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

I get the same error when syncing locally. I've read all the threads on StackOverflow but nothing has solved this issue. Relevant parts of settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}


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

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers
ALLOWED_HOSTS = ['*']

# Static asset configuration
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
share|improve this question
Error is so clear. You have not specified the backend database, and the correct credentials. in DATABASES settings – karthikr Aug 1 at 20:01
@karthikr I've tried different options for the settings.py however, in the tutorial, it doesn't specify they be filled out so I'm not sure what they should be! Can you help? – Suraj Kapoor Aug 1 at 20:06
Here follow this – karthikr Aug 1 at 20:08
@karthikr thanks, i've tried that and get the same error – Suraj Kapoor Aug 1 at 20:14
add comment (requires an account with 50 reputation)

2 Answers

In your settings put that:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',  # Or another database
        'NAME': 'database.db',                      
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      
        'PORT': '',                      
    }
}
share|improve this answer
This is using sqlite3 - am trying to setup Postgres – Suraj Kapoor Aug 2 at 14:25
Well, put Postgres then – lalo Aug 2 at 14:37
see my solution below – Suraj Kapoor Aug 2 at 15:15
add comment (requires an account with 50 reputation)
up vote 0 down vote accepted

I'm not sure why the tutorial glosses over this - I've seen similar question crop up frequently - but here are the stops I've taken that resolved the issue. It's worth reading the Postgres documentation as well - https://devcenter.heroku.com/articles/heroku-postgresql

1) Create a Postgres DB using heroku addons | grep POSTGRES in terminal

2) Connect the DB to the app - heroku addons:add heroku-postgresql:dev

3) Promote the URL to Database URL: heroku pg:promote HEROKU_POSTGRESQL_RED_URL

4) Add this into your settings.py:

DATABASES['default'] = dj_database_url.config(default=os.environ.get('DATABASE_URL'))

share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.