在 Django-mssql SQL 上运行 syncdb 时出错



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

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

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

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

调用 save() 后,我收到此错误消息(也已报告):

Creating tables ...
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:Python26libsite-packagesdjangocoremanagement__init__.py", line 459, in execute_manager
utility.execute()
File "C:Python26libsite-packagesdjangocoremanagement__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:Python26libsite-packagesdjangocoremanagementbase.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:Python26libsite-packagesdjangocoremanagementbase.py", line 232, in execute
output = self.handle(*args, **options)
File "C:Python26libsite-packagesdjangocoremanagementbase.py", line 371, in handle
return self.handle_noargs(**options)
File "C:Python26libsite-packagesdjangocoremanagementcommandssyncdb.py", line 110, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "C:Python26libsite-packagesdjangocoremanagementsql.py", line 189, in emit_post_sync_signal
interactive=interactive, db=db)
File "C:Python26libsite-packagesdjangodispatchdispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "C:Python26libsite-packagesdjangocontribauthmanagement__init__.py", line 35, in create_permissions
ctype = ContentType.objects.get_for_model(klass)
File "C:Python26libsite-packagesdjangocontribcontenttypesmodels.py", line 42, in get_for_model
defaults = {'name': smart_unicode(opts.verbose_name_raw)},
File "C:Python26libsite-packagesdjangodbmodelsmanager.py", line 134, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File "C:Python26libsite-packagesdjangodbmodelsquery.py", line 449, in get_or_create
obj.save(force_insert=True, using=self.db)
File "C:Python26libsite-packagesdjangodbmodelsbase.py", line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "C:Python26libsite-packagesdjangodbmodelsbase.py", line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "C:Python26libsite-packagesdjangodbmodelsmanager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "C:Python26libsite-packagesdjangodbmodelsquery.py", line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "C:Python26libsite-packagesdjangodbmodelssqlcompiler.py", line 909, in execute_sql
for sql, params in self.as_sql():
File "C:Python26libsite-packagesdjango_mssql-1.0.1-py2.6.eggsqlserver_adocompiler.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 中处理用户和身份验证的方式的变化。有机会我会看看源代码并尝试修补。

对 Django 1.4 的支持是在 django-mssql v1.1 中添加的

pip install django-mssql>=1.1

相关内容

  • 没有找到相关文章

最新更新