【问题标题】:When running syncdb on Django-mssql SQLInsertCompiler error在 Django-mssql SQLInsertCompiler 错误上运行 syncdb 时
【发布时间】:2012-04-13 03:23:45
【问题描述】:

这是在 Microsoft SQL Server 2005 上。 蟒蛇 2.7。 Django 1.4

Django-MSSQL 已安装并连接到数据库。

我可以读取表格,但不能插入或更新它们。在一个空数据库上阅读 django 的教程,我到了这一点:

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

调用 save() 后,我得到了这个error message(也有报道):

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

更新:我回滚到 Django 1.3,这个错误消失了。我怀疑这是 Django 在 1.4 中处理用户和身份验证的方式发生了变化。有机会我会看看源代码并尝试修补。

【问题讨论】:

    标签: python django sql-server-2005 django-mssql


    【解决方案1】:

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

    pip install django-mssql>=1.1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-17
      • 2012-02-26
      • 2023-03-04
      • 2014-09-07
      • 2014-02-04
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      相关资源
      最近更新 更多