python Bug记录-int() argument must be a string, a bytes-like object or a number, not 'dict'

代码如下:

	error_msg = ""
    if request.method == "POST":
        new_dayincome = request.POST.get("dayincome_time", None)

        total_bath = models.bathAccount.objects.filter(dayBath=new_dayincome).aggregate(bath=Sum('priceBath'))
        total_numback = models.bathAccount.objects.filter(dayBath=new_dayincome).aggregate(back=Sum('numBack'))
        total_incomebath = total_bath['bath']-total_numback['back']*10 #除去搓背的洗浴收入
        total_house = models.houseAccount.objects.filter(dayTime=new_dayincome).aggregate(house=Sum('priceHouse'))
        total_housen = total_house['house']
        total_bathHouse = total_housen+total_incomebath #洗浴收入和住房收入
        total_pay = models.expenseAccount.objects.filter(dayExpense=new_dayincome).aggregate(expense=Sum('priceAccount'))
        total_payn = total_pay['expense']
        total_income = total_bathHouse - total_payn # 每日净收入

        models.incomeAccount.objects.create(dayIncome=new_dayincome, totalBath=total_incomebath,
                                             totalBathHouse=total_bathHouse, totalHouse=total_house,
                                            totalPay=total_payn,totalIncome =total_income )
        return redirect("/adminIncome/")
        # print("total_bath:",total_bath['bath'],"total_numback:",total_numback['back'],"total_incomebath:",total_incomebath,"total_house:",total_house['house'],"")

        # total_income =  models.bathAccount.objects.values('priceBath').annotate(nums=Sum('priceBath')).filter(dayBath=new_dayincome)
        # print("total_income",total_income['nums'])

        # models.expenseAccount.objects.create(expenCate=new_expenCate, priceAccount=new_priceAccount,
        #                                      remarkAccount=new_remarkAccount, dayExpense=new_dayTime)
        # return redirect("/adminExpensive/")

    # when requesting pages, back last page
    return render(request, "admin_dayincome.html", {"error": error_msg})

因为这一块出问题

models.incomeAccount.objects.create(dayIncome=new_dayincome, totalBath=total_incomebath,
                                             totalBathHouse=total_bathHouse, totalHouse=total_house,
                                            totalPay=total_payn,totalIncome =total_income )
        return redirect("/adminIncome/")

应该是totalHouse = total_housen 因为total_house是dic类型,所以total_housen=total_house[‘house’]是int类型。

你可能感兴趣的:(Python,BUG记录,Python,项目,Python,Bug汇总)