0
Oscar Commerceプロジェクトの出荷方法の開発では、2つの属性が必要であることがわかりました。 1つは製品重量を表す浮動小数点値(私は製品を計量するためにScale
classを使用しています)と、出荷コンテナモデルにリンクするエンティティ属性を含んでいます。Django-OscarでProductAttributesをプログラム的に定義する場所
属性は、出荷が必要な製品クラスに割り当てる必要があります。どこで/私はそれらを作成するのですか?私は次のコードを持っていますが、どこに合っているのか分かりません。
from oscar.core.loading import get_model
ProductAttribute = get_model('catalogue', 'ProductAttribute')
ProductAttribute.objects.get_or_create(code='weight',
product_class=[product class],
defaults={
'name': 'Weight',
'type': ProductAttribute.FLOAT,
})
ProductAttribute.objects.get_or_create(code='box',
product_class=[product class],
defaults={
'name': 'Box used for shipping'
'type': ProductAttribute.ENTITY,
})
このコードを追加する場所はどこですか?