2010-06-01 63 views
5

我通过Django的教程工作,并收到以下错误,当我运行初始蟒蛇manage.py执行syncdb:Django的教程说我没有设置DATABASE_ENGINE设置尚未...但我有

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. 
    } 
} 

我猜这是简单的东西,但为什么没有看到发动机设置?

回答

13

它看起来像你使用的是早期版本的Django。这种设置数据库配置的方式来自Django 1.2,但是你得到的错误是来自1.1。如果您使用1.1版,请使用this version of the tutorial

+0

谢谢,这绝对是问题所在。后续问题:我使用--no-site-wrappers创建了virtualenvwrapper,然后安装了Django。看来我在virtualenvwrapper中有Django 1.2.1,但在我的全球站点包中有Django 1.1.1。你知道为什么这个settings.py文件会指向全局站点包,而不是在virtualenv中安装的吗? – Joe 2010-06-01 16:09:19

+0

那么,它实际上是'manage.py',它指的是全局版本而不是virtualenv - 这个设置适合你在virtualenv(1.2)中使用的版本。愚蠢的问题:你有没有激活virtualenv? – 2010-06-01 16:27:36

+0

总是值得问这些愚蠢的问题,因为我很可能没有。我只是再试一次(virtualenv激活),现在关闭到一个不同的错误:django.core.exceptions.ImproperlyConfigured:加载MySQLdb模块时出错:没有模块名为MySQLdb - 作为一个新手到Stackoverflow,我猜我应该单独发布这个?谢谢你的帮助。 – Joe 2010-06-01 16:36:38

2
'ENGINE': 'mysql', 
'NAME': 'dj_tut', 

并且您将要设置用户和密码。

-3

在命令提示符下,你应该写:

edit settings.py 

那么就会有一个新的模块编辑

settings.py 
1

同样的问题经常发生在我身上,每次的问题是循环依赖在sttings.py和另一个模块之间。