0
のエラーは私はジャンゴでSUMPRODUCTのクエリを実行しようとしているガイド:は "ベース10と()int型のリテラル無効" DecimalFieldは
merchandise_value = Product.objects.all()\
.aggregate(merch_value=Sum(F('qty_ordered')*F('msrp')))
'msrp'
は(2 decimal_places
付き)DecimalField
フィールドです。 'qty_ordered'
はIntegerField
です。私はint(float(F('msrp')))
またはint(float(str(F('msrp'))))
のようなクレイジーなことを行う場合でも、私はまだ取得:
invalid literal for int() with base 10: 'F(msrp)'
他の同様の質問は、私が使用しているものと同様の解決策を提案します。私は何をねじ込みましたか?そしておそらくもっと重要なのは、どうしてその回線にint()
が組み込まれているのですか?私は明示的にint()
と呼んでいません。
ああ、ありがとう。ここに記載されています:https://docs.djangoproject.com/en/1.9/ref/models/expressions/#using-f-with-annotations – Escher