我的程序中似乎有一个bug,这很奇怪。为了测试,我在manage.py外壳上运行了一些非常简单的命令。
models = Model.objects.all()
for model in models :
print model.field
output:
0
0
0
0
100004398604871
576962717
576962717
576962717现在是奇怪的部分了:
Model.objects.extra(where = ["field= 576962717"])
output:
[]
Model.objects.extra(where = ["field= 100004398604871"])
output:
[]
# But!!
Model.objects.extra(where = ["field= 0"])
output:
[a bunch of models, aka this one worked]因此,很明显,大的int比较出了问题。我检查了我的mysql数据库结构和我的模型,以确保它们是一致的,并且它们确实是一致的:
我的mysql参数被标记为bigint(11)
我的django模型是BigIntegerField(editable=False)
有什么想法吗?谢谢
发布于 2012-10-03 16:41:10
哦,天哪,我太慢了,我忘了它应该是大整数(20)而不是11,对不起!
https://stackoverflow.com/questions/12704720
复制相似问题