Elastic bobsleigh not creating RDS parameters

I follow this guide to create a Django application on AWS.

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html

I managed to get everything that works with the local sqlite database, but I'm trying to push the application to the production server. After going through the initialization process of Elastic Beanstalk, I decided to create an instance of RDS.

My mysite / settings.py looks like this:

import os

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': os.environ['RDS_DB_NAME'], 'USER': os.environ['RDS_USERNAME'], 'PASSWORD': os.environ['RDS_PASSWORD'], 'HOST': os.environ['RDS_HOSTNAME'], 'PORT': os.environ['RDS_PORT'], } } 

I should have access to the RDS settings at the moment, but I do not. The manage.py file becomes unresponsive.

 (djangodev)laptop-id:mysite user-name$ python manage.py runserver Unknown command: 'runserver' Type 'manage.py help' for usage. (djangodev)laptop-id:mysite use-name$ python manage.py Usage: manage.py subcommand [options] [args] Options: -v VERBOSITY, --verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output --settings=SETTINGS The Python path to a settings module, eg "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used. --pythonpath=PYTHONPATH A directory to add to the Python path, eg "/home/djangoprojects/myproject". --traceback Print traceback on exception --version show program version number and exit -h, --help show this help message and exit Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 376, in execute sys.stdout.write(self.main_help_text() + '\n') File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 242, in main_help_text for name, app in six.iteritems(get_commands()): File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 109, in get_commands apps = settings.INSTALLED_APPS File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__ self._setup(name) File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Users/andrewcopp/Developer/mysite/mysite/settings.py", line 17, in <module> 'NAME': os.environ['RDS_DB_NAME'], # Or path to database file if using sqlite3. File "/tmp/djangodev/bin/../lib/python2.7/UserDict.py", line 23, in __getitem__ raise KeyError(key) KeyError: 'RDS_DB_NAME' 

Any idea on what I might forget? Any additional information I can provide so that everything is clear.

+4
source share
1 answer

You need a local backup to another database in the settings.

In the settings.py file, replace the DATABASE variable as follows:

 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 local_settings.py in the same directory as 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 the local_settings.py file to the .gitignore file.

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

Most of all, this is a copy of the paste from this blog post that I found: http://grigory.ca/2012/09/getting-started-with-django-on-aws-elastic-beanstalk/

0
source

Source: https://habr.com/ru/post/1496281/


All Articles