0
votes

I had deployed my django app on elasticbeanstalk but when I am connecting with rds is shows this error:

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.
container_command 01_migrate in .ebextensions/django.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

Here is my setting:

if 'aam9tdmg0cwj1k.cugucrimdqma.ap-south-1.rds.amazonaws.com' in os.environ:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.environ['aam9tdmg0cwj1k'],
        'USER': os.environ['liveimage'],
        'PASSWORD': os.environ['liveimage123'],
        'HOST': os.environ['aam9tdmg0cwj1k.cugucrimdqma.ap-south-1.rds.amazonaws.com'],
        'PORT': os.environ['5432']
    }
}

There is no indent error.

1
I think you have misunderstood what a dictionary is. None of those values will be keys in the os.environ dictionary. - Daniel Roseman

1 Answers

0
votes

First set the value of host in the key HOST of environment and then your first line should be like:

if os.environ.get('HOST',None) == 'aam9tdmg0cwj1k.cugucrimdqma.ap-south-1.rds.amazonaws.com':

If you don't want to set an environment variable, give a default value like:

import environ
env = environ.Env()
DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': env('DB_NAME', default='aam9tdmg0cwj1k'),
    'USER': env('DB_USER', default='liveimage'),
    'PASSWORD': env('DB_PASSWORD', default='liveimage123'),
    'HOST': env('DB_HOST', default='aam9tdmg0cwj1k.cugucrimdqma.ap-south-1.rds.amazonaws.com'),
    'PORT': env('DB_PORT', default='5432')
}

}