How to properly configure DATABASE settings in

First time Django user here. I’m trying to deploy my project to Heroku following a set of instructions from the book, Python Crash Course by Eric Matthes. It seems that between the time Mr. Matthes published his book and the time I got started on my current project, some things must have changed with the way Django and Heroku works that renders this part of the tutorial inadequate to the task of properly deploying a Django web app.

Everytime I try to migrate the database on Heroku in the CL, I get the following error:

django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the NAME or OPTIONS[‘service’] value.

As it stands, my DATABASE settings are defined in two places. One seems to specify default database as a sqlite3 database:

    'default': {
       'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',

The second mention is in an if-statement that checks if the file is being run as a deployed app, in which case it attempts to set the database to what I’m told is Heroku’s default choice of PostGres. In addition, it also dictates other settings for when the file is being run as part of a deployed app. This is from the instructions in Eric Mathes’ book.

# Heroku settings 
cwd = os.getcwd() # Gets the current working directory the file is running from.  
if cwd == '/app' or cwd[:4] == '/tmp': 
    import dj_database_url # import dj_database_url to help configure the database on Heroku
        'default' : dj_database_url.config(default='postgres://localhost')

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

    # Allow all host headers. 
    ALLOWED_HOSTS = ['*'] # ensures that Django will serve the project from Heroku's URL 

    # Static asset configuration 
    BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # set up the project to serve static files correctly on Heroku
    STATIC_ROOT = 'staticfiles'
        os.path.join(BASE_DIR, 'static'),

Let me know if anyone wants to see the full file. I didn’t include it since the errors I’m getting at this stage seem to indicate that the problem stems from the database settings, and I didn’t want to make everyone hunt around for that bit.