我遇到了一个奇怪的问题,在成功执行django syncdb操作之后,没有在Server 2008上创建任何表。
以下是控制台输出:
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'xxx'): admin
Email address: xxx@gmail.com
Password: admin
Password (again): admin
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Finished "E:\Users\xxx\Documents\Eclipse Workspace\PyDev\chaos\manage.py syncdb" execution.以下是我对django的settings.py:
# SQL Server 2008
DATABASES = {
'default': {
'ENGINE': 'django_pyodbc',
'HOST': 'localhost',
'NAME': 'Chaos',
'USER': 'chaos',
'PASSWORD': 'admin',
'OPTIONS': {
'driver': 'SQL Server Native Client 10.0',
'MARS_Connection': True,
},
}
}请帮助找出根本原因。谢谢。
发布于 2014-02-20 13:34:23
这几天我遇到了这个问题。
然后我找到了这个https://github.com/lionheart/django-pyodbc/issues/38
Django 1.6现在假设自动提交默认为True,这意味着它必须显式地设置为使用1.6 (例如,syncdb看起来成功,但不创建任何表)。
解决方案是在选项中添加“autocommit”:True,如下所示:
# SQL Server 2008
DATABASES = {
'default': {
'ENGINE': 'django_pyodbc',
'HOST': 'localhost',
'NAME': 'Chaos',
'USER': 'chaos',
'PASSWORD': 'admin',
'OPTIONS': {
'driver': 'SQL Server Native Client 10.0',
'autocommit': True,
'MARS_Connection': True,
},
}
}https://stackoverflow.com/questions/21682168
复制相似问题