ImproperlyConfigured("settings.DATABASES is improperly configured. ") error when trying to set up Django

11,542

Solution 1

I ran into the same issue. 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.

Solution 2

Try add these lines after your DATABASE setting in your settings.py

# Your Database setting. 
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',  # Or path to database file if using sqlite3.
        'USER': '',  # Not used with sqlite3.
        'PASSWORD': '',  # Not used with sqlite3.
        'HOST': '',  # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',  # Set to empty string for default. Not used with sqlite3.
    }
}
# Add these two lines.
import dj_database_url
DATABASES['default'] = dj_database_url.config(default='sqlite://db/sqlite3.db')

Solution 3

Thank you very much Chatri as you suggested adding the default='sqlite://db/sqlite3.db' fixed the issue.

Share:
11,542
fox
Author by

fox

Updated on June 18, 2022

Comments

  • fox
    fox almost 2 years

    Attempting to follow the instructions here to set up a Django instance on Heroku.

    Got as far as the installation of Celery, up to the following step:

    $ python manage.py syncdb
    

    when I get the following error:

    raise ImproperlyConfigured("settings.DATABASES is improperly configured. "django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

    I believe that I have my settings.py file in the right place (project-name/project-name), and I'm running django 1.4.3, but when I try to run manage.py diffsettings, I get the following output:

    BROKER_BACKEND = 'django' ### DATABASES = {'default': {'ENGINE': 'django.db.backends.dummy', 'TEST_MIRROR': None, 'NAME': '', 'TEST_CHARSET': None, 'TIME_ZONE': 'UTC', 'TEST_COLLATION': None, 'PORT': '', 'HOST': '', 'USER': '', 'TEST_NAME': None, 'PASSWORD': '', 'OPTIONS': {}}}

    Absolutely no idea where the django.db.backends.dummy entry comes from, my settings.py has 'ENGINE': 'django.db.backends.postgresql_psycopg2', which I assume is the correct entry even though the Heroku instructions don't tell you to update it at any point.

    Any thoughts what I need to edit here?