Django 教程说我还没有设置 DATABASE_ENGINE 设置...但我已经设置了

2024-04-19

我正在完成 Django 教程,并在运行初始 python manage.pysyncdb 时收到以下错误:

Traceback (most recent call last):
File "manage.py", line 11, in <module>
  execute_manager(settings)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362 in execute_manager
  utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 303, in execute
  self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
  self.execute(*args, **options.__dict__)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 222, in execute
  output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 351, in handle
  return self.handle_noargs(**options)
File "/Library/Python/2.6/site-packages/django/core/management/commands/syncdb.py", line 49, in handle_noargs
  cursor = connection.cursor()
File "/Library/Python/2.6/site-packages/django/db/backends/dummy/base.py", line 15, in complain
  raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet."
django.core.exceptions.ImproperlyConfigured: You haven't set the DATABASE_ENGINE setting yet.

我的 settings.py 看起来像:

DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
    'NAME': 'dj_tut',                      # Or path to database file if using sqlite3.
    'USER': '',                      # Not used with sqlite3.
    'PASSWORD': '',                  # Not used with sqlite3.
    'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
    'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
  }
}

我猜这很简单,但为什么它看不到引擎设置?


您似乎使用的是早期版本的 Django。这种设置数据库配置的方法来自 Django 1.2,但您收到的错误来自 1.1。如果您使用的是 1.1 版本,请使用此版本的教程 http://docs.djangoproject.com/en/1.1/intro/tutorial01/.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Django 教程说我还没有设置 DATABASE_ENGINE 设置...但我已经设置了 的相关文章

随机推荐