简体   繁体   English

在Django-mssql SQLInsertCompiler上运行syncdb时出现错误

[英]When running syncdb on Django-mssql SQLInsertCompiler error

This is on Microsoft SQL Server 2005. Python 2.7. 这是在Microsoft SQL Server 2005上。Python2.7。 Django 1.4 Django 1.4

Django-MSSQL is installed and connecting to the database. Django-MSSQL已安装并连接到数据库。

I can read tables, but not insert or update them. 我可以读取表,但不能插入或更新它们。 Working through django's tutorial on an empty database I get to this point: 在空数据库上浏览django的教程,我明白了这一点:

# Save the object into the database. You have to call save() explicitly.
>>> p.save()

After save() is called I get this error message (which has also been reported): 在调用save()之后,我得到此错误消息 (也已报告):

Creating tables ...
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python26\lib\site-packages\django\core\management\__init__.py", line 459, in execute_manager
utility.execute()
File "C:\Python26\lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python26\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python26\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "C:\Python26\lib\site-packages\django\core\management\base.py", line 371, in handle
return self.handle_noargs(**options)
File "C:\Python26\lib\site-packages\django\core\management\commands\syncdb.py", line 110, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "C:\Python26\lib\site-packages\django\core\management\sql.py", line 189, in emit_post_sync_signal
interactive=interactive, db=db)
File "C:\Python26\lib\site-packages\django\dispatch\dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "C:\Python26\lib\site-packages\django\contrib\auth\management\__init__.py", line 35, in create_permissions
ctype = ContentType.objects.get_for_model(klass)
File "C:\Python26\lib\site-packages\django\contrib\contenttypes\models.py", line 42, in get_for_model
defaults = {'name': smart_unicode(opts.verbose_name_raw)},
File "C:\Python26\lib\site-packages\django\db\models\manager.py", line 134, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File "C:\Python26\lib\site-packages\django\db\models\query.py", line 449, in get_or_create
obj.save(force_insert=True, using=self.db)
File "C:\Python26\lib\site-packages\django\db\models\base.py", line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "C:\Python26\lib\site-packages\django\db\models\base.py", line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "C:\Python26\lib\site-packages\django\db\models\manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "C:\Python26\lib\site-packages\django\db\models\query.py", line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py", line 909, in execute_sql
for sql, params in self.as_sql():
File "C:\Python26\lib\site-packages\django_mssql-1.0.1-py2.6.egg\sqlserver_ado\compiler.py", line 207, in as_sql
sql, params = super(SQLInsertCompiler, self).as_sql(*args, **kwargs)
ValueError: need more than 1 value to unpack

UPDATE: I rolled back to Django 1.3 and this error went away. 更新:我回滚到Django 1.3,此错误消失了。 I suspect it is a change in how Django handles the users and authentication in 1.4. 我怀疑这是Django在1.4中处理用户和身份验证的方式的变化。 I'll take a look at source when I get a chance and try to patch. 如果有机会,我将看一下源代码并尝试进行修补。

django-mssql v1.1添加了对Django 1.4的支持

pip install django-mssql>=1.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM