编辑:事实证明我不相信迁移与导致此错误有任何关系。
在下面的代码部分中,我选择聚合值并将这些值分配回使用模型,我发现自从我将应用程序从 django 开发服务器迁移到 apache 后,这些值没有被分配。
我的调试输出显示,在分配了这些值之后,该值从未实际应用于模型实例,当稍后进行保存时,这也反映了模型实例中仍然存在零。
蟒蛇代码
cursor.execute("""select CUSTNBR,
FROMDATE,
sum(DECTHERMS) as DECTHERMS,
max(PRICE) as PRICE,
sum(SALESDLRS) as SALESDLRS,
sum(MCFS) as MCFS
from LQPPNATGAS
where CUSTNBR = ? and
FROMDATE <> '20000000'
group by CUSTNBR, FROMDATE """,str(cust_number))
row = cursor.fetchone()
while row:
if str(row.FROMDATE)[0:4] >= str(oldest_year):
b = Usage.objects.filter(user_id=user_id,from_date=row.FROMDATE)
b[0].decatherms = row.DECTHERMS
b[0].price = row.PRICE
b[0].sales_dollars = row.SALESDLRS
b[0].mcf = row.MCFS
b[0].save(update_fields=['decatherms','price','sales_dollars','mcf'])
print >> sys.stderr ,str(b[0].sales_dollars)+"="+str(row.SALESDLRS)
row = cursor.fetchone()
在error.log中输出
[Thu Aug 29 07:47:15 2013] [error] 0.00=168.22
[Thu Aug 29 07:47:15 2013] [error] 0.00=16.78
[Thu Aug 29 07:47:15 2013] [error] 0.00=1107.88
[Thu Aug 29 07:47:15 2013] [error] 0.00=676.85
[Thu Aug 29 07:47:15 2013] [error] 0.00=28.38
[Thu Aug 29 07:47:15 2013] [error] 0.00=876.94
[Thu Aug 29 07:47:15 2013] [error] 0.00=833.21
[Thu Aug 29 07:47:15 2013] [error] 0.00=26.33
[Thu Aug 29 07:47:15 2013] [error] 0.00=130.85
[Thu Aug 29 07:47:15 2013] [error] 0.00=1058.53