1

我是 Django 的新手。我正在按照教程中的说明进行操作。当我运行时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

请让我知道我在哪里犯了错误。

4

5 回答 5

5

阅读您的错误消息:

配置不当:您尚未设置数据库 ENGINE 设置。

DATABASES入您的settings.py. 你至少需要ENGINE数据库NAME

于 2012-05-21T10:36:03.760 回答
1

你需要在 settings.py 中做以下两件事

  1. 在数据库字典中添加数据库引擎和凭据。
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqllite3',
        'NAME': '/home/yourname/mydb', 
        'USER': '',   
        'PASSWORD': '',  
        'HOST': '',        
        'PORT': '',  
}
}
  1. 将您的应用添加到 installed_app 列表
INSTALLED_APPS = (
    'com.example.myapp',
    ....
于 2012-05-21T13:06:53.073 回答
1
You haven't set the database ENGINE setting yet.

确保您在 settings.py 中拥有正确的数据库凭据

于 2012-05-21T10:37:30.540 回答
1

我在 settings.py 文件中添加了数据库配置:

现在在Django 1.8.x上,它完全支持迁移

syncdb将在 1.9 版中完全删除

尝试使用makemigrations并改为migrate

python manage.py makemigrations app1 app2 app3

将在每个应用迁移文件夹中制作迁移脚本

python manage.py migrate

将查看数据库django_migrations表和迁移文件夹并将迁移更改。

于 2015-10-19T14:42:32.257 回答
0

安装 MySQL-python 为我工作!

于 2013-09-28T21:34:43.010 回答