【发布时间】:2012-05-27 20:37:03
【问题描述】:
我是 Django 新手。我正在按照tutorial 中的说明进行操作。
当我运行python manage.py syncdb 时,我收到以下错误:
D:\MyDev\DjnagoProject\mysite>python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 420, in execute_from_command_
line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 371, in handle
return self.handle_noargs(**options)
File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "C:\Python27\lib\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.
添加信息: Python版本:2.7.2, django 版本: (1, 4, 0, 'alpha', 1) 操作系统:Windows XP
请让我知道我在哪里犯了错误。
【问题讨论】:
-
我不知道你在关注哪个教程,但official tutorial 明确提到首先设置数据库引擎然后运行
python manage.py syncdb。 -
我也在关注你在这里提到的同一份文件。这是我根据setting.py文件中的要求修改的数据库值 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', ' mysql'、'sqlite3' 或 'oracle'。 'NAME': r'D:/MyDev/DjnagoProject/mysite/myDev.db', # 如果使用 sqlite3,则为数据库文件的路径。
-
向我们展示与数据库部分相关的 settings.py 文件的内容。还有你正在使用哪个数据库,我建议你使用为 python >2.5 内置的 sqlite3