2

我按照以下文档在 AWS Elastic Beanstalk 上安装了 django。 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html

现在我开始编写我的第一个 djangoapp,著名的民意调查。问题是当我使用命令python manage.py startapp polls时,我收到一个错误 Unknown Command : startapp。当我使用python manage.py syncdb时,错误 Unknown Command : syncdb.

当我使用 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 "/tmp/djangodev/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/tmp/djangodev/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 366, in execute
    sys.stdout.write(self.main_help_text() + '\n')
  File "/tmp/djangodev/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 231, in main_help_text
    for name, app in get_commands().iteritems():
  File "/tmp/djangodev/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands
    apps = settings.INSTALLED_APPS
  File "/tmp/djangodev/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/tmp/djangodev/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/tmp/djangodev/local/lib/python2.7/site-packages/django/conf/__init__.py", line 93, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/tmp/djangodev/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/mysite/mysite/settings.py", line 15, in <module>
    'NAME': os.environ['RDS_DB_NAME'],                      # Or path to database file if using sqlite3.
  File "/tmp/djangodev/lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'RDS_DB_NAME'

如何度过这个难关??

谢谢

4

1 回答 1

1

看起来你有一个使用环境变量的设置:

  • 如果您使用os.environ['RDS_DB_NAME']as 数据库,请检查数据库部分中的 settings.py。
  • RDS_DB_NAME检查您是否可能在您的~/.profileor中配置了环境变量,~/.bashrc或者在使用 manage.py 后~/.bash_profile尝试使用导出命令export RDS_DB_NAME=my_dabatase_name
于 2014-06-12T16:26:46.493 回答