我正在处理Django教程并在运行初始python manage.py syncdb时收到以下错误:
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.
}
}
我猜这很简单,但为什么不看引擎设置呢?
答案 0 :(得分:13)
看起来您正在使用早期版本的Django。设置数据库配置的方式来自Django 1.2,但是你得到的错误来自1.1。如果您使用的是版本1.1,请使用this version of the tutorial。
答案 1 :(得分:2)
'ENGINE': 'mysql',
'NAME': 'dj_tut',
您将需要设置用户和密码。
答案 2 :(得分:1)
同样的问题经常发生在我身上,每次问题都是sttings.py和另一个模块之间的循环依赖。
答案 3 :(得分:-3)
在命令提示符下,您应该写:
edit settings.py
然后会有一个用于编辑
的新模块settings.py