我在下面偶然:的MySQL/sqlite3的
def save_formset(self, request, form, formset, change):
instances = formset.save(commit=False)
bargain_id = 0
total_price = Decimal(0)
for instance in instances:
if isinstance(instance, BargainProduct):
total_price += instance.quantity * instance.product.price
bargain_id = instance.id
instance.save()
updateTotal = Bargain.objects.get(id=bargain_id)
updateTotal.total_price = total_price - updateTotal.discount_price
updateTotal.save()
此代碼爲我工作在我的本地MySQL安裝但是,對SQLite3的運行我的實際測試環境*我得到的「甩賣匹配查詢呢不存在。」錯誤..
我認爲這是由於保存在SQLite上的實例不同的層次結構..但是,它似乎他們運行(應該)行爲相同..?
*我不能Python支持我的liveserver ATM重新編譯的MySQL因此多數民衆贊成一個沒有去