问题描述
我已经使用库在我的一个Django项目中实现历史记录跟踪,它可以正常工作,直到我开始对我的项目进行更改,将其移动到具有Cloud SQL的Google Application Engine。现在,在布尔型字段中似乎失败了以下警告:
I've used django-simple-history library to implement history tracking in one of my Django project and it worked fine until I started to make changes in my project to move it to Google Application Engine with Cloud SQL. Now, it seems to fail on the Boolean fields with the below warning:
Warning at /admin/
Incorrect integer value: 'True' for column 'is_superuser' at row 1
以下部分代码似乎是导致simple_history / models.py文件中的问题,如果模型中有任何布尔字段,则会创建历史记录:
Below part of the code seems to be causing the issue in simple_history/models.py file, which breaks on creating history if there are any Boolean fields in the model:
def create_historical_record(self, instance, type):
history_user = getattr(instance, '_history_user', None)
manager = getattr(instance, self.manager_name)
attrs = {}
for field in instance._meta.fields:
attrs[field.attname] = getattr(instance, field.attname)
manager.create(history_type=type, history_user=history_user, **attrs)
这个工作在我的机器上找到,但在谷歌应用程序引擎上发现。请建议。
This works find on my machine but breaks on google app engine. Please suggest.
更新:解决
MySQLdb库已在我的案件。通过注释BooleanType:Bool2Str行,在convert.py脚本中删除了整数转换的布尔值。
The MySQLdb library was customized in my case. Boolean to integer conversion was removed in converter.py script by commenting the line "BooleanType: Bool2Str".
推荐答案
到目前为止,我知道Google云支持Django 1.4版,可能是原因,Django 1.5布尔字段更改为true / false而不是0,1。
As far i know Google cloud was supporting Django version 1.4, it could be reason, After Django 1.5 boolean fields changed to true/false instead of 0, 1.
我建议您将本地django版本更改为1.4,然后尝试。
I would suggest you to change your local django version to 1.4 and try.
这篇关于Django整数值不正确:第1行的列'is_superuser'为'True'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!