我是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,&#39; alpha&#39;,1) 操作系统:Windows XP
请让我知道我在哪里犯了错误。
答案 0 :(得分:5)
阅读您的错误消息:
NotperlyConfigured:您尚未设置数据库ENGINE设置 爱好。强>
答案 1 :(得分:1)
You haven't set the database ENGINE setting yet.
确保您有正确的DB credentials in settings.py。
答案 2 :(得分:1)
你需要在settings.py
中做两件事DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqllite3', 'NAME': '/home/yourname/mydb', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': '', } }
INSTALLED_APPS = ( 'com.example.myapp', ....
答案 3 :(得分:1)
我在settings.py文件中添加了数据库配置:
现在 Django 1.8.x ,它完全支持迁移。
版本1.9 中将完全删除syncdb
尝试使用 makemigrations 和迁移
python manage.py makemigrations app1 app2 app3
将在每个应用迁移文件夹中创建迁移脚本
python manage.py migrate
将查看数据库 django_migrations 表和迁移文件夹,并将迁移更改。
答案 4 :(得分:0)
安装MySQL-python为我工作!