django-oscar集成错误

时间:2015-12-01 15:25:35

标签: python django django-oscar

我将电子商务集成到我的代码中。并遇到产品问题。当我用简单的

更新models.py
class MyProduct(AbstractProduct):
    pass

甚至使用AbstractProduct扩展我的Package模型并尝试创建迁移,出现下一个错误。

catalogue.Product.product_class: (fields.E304) Reverse accessor for 'Product.product_class' clashes with reverse accessor for 'Package.product_class'.
    HINT: Add or change a related_name argument to the definition for 'Product.product_class' or 'Package.product_class'.
catalogue.Product.product_class: (fields.E305) Reverse query name for 'Product.product_class' clashes with reverse query name for 'Package.product_class'.
    HINT: Add or change a related_name argument to the definition for 'Product.product_class' or 'Package.product_class'.
catalogue.ProductAttributeValue: (fields.E336) The model is used as an intermediate model by 'ckanwrap.Package.attributes', but it does not have a foreign key to 'Package' or 'ProductAttribute'.
catalogue.ProductCategory: (fields.E336) The model is used as an intermediate model by 'ckanwrap.Package.categories', but it does not have a foreign key to 'Package' or 'Category'.
catalogue.ProductRecommendation: (fields.E336) The model is used as an intermediate model by 'ckanwrap.Package.recommended_products', but it does not have a foreign key to 'Package' or 'Product'.
ckanwrap.Package.product_class: (fields.E304) Reverse accessor for 'Package.product_class' clashes with reverse accessor for 'Product.product_class'.
    HINT: Add or change a related_name argument to the definition for 'Package.product_class' or 'Product.product_class'.
ckanwrap.Package.product_class: (fields.E305) Reverse query name for 'Package.product_class' clashes with reverse query name for 'Product.product_class'.
    HINT: Add or change a related_name argument to the definition for 'Package.product_class' or 'Product.product_class'.
ckanwrap.Package.recommended_products: (fields.E335) The model is used as an intermediate model by 'ckanwrap.Package.recommended_products', but it has more than one foreign key to 'Product', which is ambiguous. You must specify which foreign key Django should use via the through_fields keyword argument.
    HINT: If you want to create a recursive relationship, use ForeignKey("self", symmetrical=False, through="ProductRecommendation").

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

如果有人仍然遇到此问题,解决方案是创建一个与oscar使用相同名称的类。在这种情况下,它将是Product。

from oscar.apps.catalogue.abstract_models import AbstractProduct
from django.db import models


class Product(AbstractProduct):
     additional_field = models.CharField(max_length=200)

from oscar.apps.catalogue.models import *