Storeliquor.objects.filter(storeID=ID_Store,liquorID.BottleSize='750 ML',custom=False).update(StorePrice = liquorID.ShelfPrice)Storeliquor.objects.filter(storeID=ID_Store,custom=False).update(StorePrice = (float(liquorID.OffPremisePrice)) + (float(S750Increase)))Storeliquor.objects.filter(storeID=ID_Store,custom=False).update(StorePrice = (float(liquorID.OffPremisePrice) * (float(S750Increase)/100)) + float(liquorID.OffPremisePrice))解决方法 你不能在参数名中使用点,所以这部分liquorID.BottleSize =’750 ML’会导致SyntaxError
在过滤器中使用相关模型使用跨越关系的查找
https://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships
Django offers a powerful and intuitive way to “follow” relationships in lookups,taking care of the sql JOINs for you automatically,behind the scenes. To span a relationship,just use the fIEld name of related fIElds across models,separated by double underscores,until you get to the fIEld you want.
所以你的陈述应该是这样的:
Storeliquor.objects.filter(storeID=ID_Store,liquorID__BottleSize='750 ML',custom=False).update(StorePrice=liquorID__ShelfPrice)总结
以上是内存溢出为你收集整理的python – django语法错误:关键字不能是表达式全部内容,希望文章能够帮你解决python – django语法错误:关键字不能是表达式所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)