[Django]-Elastic Beanstalk not creating RDS Parameters

0👍

You need a local fallback to a different database in settings.

In your settings.py file, replace the DATABASE variable with this:

DATABASES = {}

try:
    from local_settings import *
except ImportError, e:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': os.environ['RDS_DB_NAME'],
            'USER': os.environ['RDS_USERNAME'],
            'PASSWORD': os.environ['
            'HOST': os.environ['RDS_HOSTNAME'],
            'PORT': os.environ['RDS_PORT'],
        }
    }

Now create a local_settings.py in the same directory as your settings.py and enter the following code:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'db.djangodb',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = ()
TEMPLATE_DIRS = ()

Now add your local_settings.py file to your .gitignore file.

Run $ python manage.py syncdb and now you can run the django server locally.

Most of this is copy pasta from this blog post I found:
http://grigory.ca/2012/09/getting-started-with-django-on-aws-elastic-beanstalk/

Leave a comment