【发布时间】:2020-04-09 04:52:55
【问题描述】:
from oscar.apps.catalogue.abstract_models import AbstractProduct
from oscar.core.compat import AUTH_USER_MODEL
from django.db import models
class Product(AbstractProduct):
seller = models.ForeignKey(
AUTH_USER_MODEL,
on_delete=models.CASCADE,
null=True)
from oscar.apps.catalogue.models import *
我将此代码添加到分叉目录模型中> 我想在仪表板中显示它,Image of dashboard and dropdown box 我尝试了 admin.site.register 但它不起作用。
这是表单覆盖的代码,当我分叉和覆盖时它不起作用,但是当我更改核心中的代码时它起作用。
from oscar.apps.dashboard.catalogue.forms import ProductForm
from oscar.core.loading import get_class, get_classes, get_model
from yourappsfolder.catalogue.models import Product
class SellerField(ProductForm):
class Meta(ProductForm.Meta):
model =Product
fields = [
'title','seller', 'upc', 'description', 'is_public', 'is_discountable', 'structure']
【问题讨论】:
-
需要覆盖对应的dashboard表单:github.com/django-oscar/django-oscar/blob/master/src/oscar/apps/…
-
@solarissmoke 我确实分叉了它,我将代码添加到了问题中,当我编辑核心时它可以工作,但是当我分叉时它不起作用(它读取并且没有错误),应用程序是也安装在设置中并删除了#'oscar.apps.dashboard.catalogue',
标签: django python-3.x django-oscar