我正在关注本教程,以努力在 AWS 上创建一个 Django 应用程序。
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
我能够使用本地 sqlite 数据库使一切工作,但我正在尝试将应用程序推送到生产服务器。在执行 Elastic Beanstalk 初始化过程时,我选择创建一个 RDS 实例。
我的 mysite/settings.py 看起来像这样:
导入操作系统
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'],
}
}
此时我应该可以访问 RDS 参数,但我没有。manage.py 文件变为无响应。
(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, e.g.
"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, e.g.
"/home/djangoprojects/myproject".
--traceback Print traceback on exception
--version show program's 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'
关于我可能忽略的任何想法?我可以提供任何更多信息以使事情变得清晰