在Django Oscar中自定义仪表板目录形式不起作用

问题描述 投票:0回答:1

我遵循了django oscar的主要文档。并且我正在尝试将新字段添加到名为video_url的产品中。

首先,我将新字段添加到产品模型中,并且效果很好。catalogue / models.py

from django.db import models

from oscar.apps.catalogue.abstract_models import AbstractProduct

class Product(AbstractProduct):
    video_url = models.URLField(null=True, blank=True)

from oscar.apps.catalogue.models import *

然后,我继续自定义目录仪表板,但似乎我没有更改任何东西,没有错误或任何错误。

dashboard / caralogue / forms.py

from oscar.apps.dashboard.catalogue.forms import ProductForm as CoreProductForm

class ProductForm(CoreProductForm):
    class Meta(CoreProductForm.Meta):
        fields = ['title', 'upc', 'description', 'is_public', 'is_discountable', 'structure', 'video_url']

myproject / settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # 'dashboard.catalogue',

    # Oscar
    'django.contrib.sites',
    'django.contrib.flatpages',

    'oscar',
    'oscar.apps.analytics',
    'oscar.apps.checkout',
    'oscar.apps.address',
    'oscar.apps.shipping',

    # My Catalogue
    'catalogue.apps.CatalogueConfig',
    # 'oscar.apps.catalogue',
    'oscar.apps.catalogue.reviews',
    'oscar.apps.partner',
    'oscar.apps.basket',
    'oscar.apps.payment',
    'oscar.apps.offer',
    'oscar.apps.order',
    'oscar.apps.customer',
    'oscar.apps.search',
    'oscar.apps.voucher',
    'oscar.apps.wishlists',
    'oscar.apps.dashboard',
    'oscar.apps.dashboard.reports',
    'oscar.apps.dashboard.users',
    'oscar.apps.dashboard.orders',

    # My Catalogue dashboard
    'dashboard.catalogue.apps.CatalogueDashboardConfig',
    # 'oscar.apps.dashboard.catalogue',
    'oscar.apps.dashboard.offers',
    'oscar.apps.dashboard.partners',
    'oscar.apps.dashboard.pages',
    'oscar.apps.dashboard.ranges',
    'oscar.apps.dashboard.reviews',
    'oscar.apps.dashboard.vouchers',
    'oscar.apps.dashboard.communications',
    'oscar.apps.dashboard.shipping',

    # 3rd-party apps that oscar depends on
    'widget_tweaks',
    'haystack',
    'treebeard',
    'sorl.thumbnail',
    'django_tables2',
]
django django-oscar
1个回答
0
投票

您的app.py文件必须为

   import oscar.apps.dashboard.catalogue.apps as apps


   class CatalogueDashboardConfig(apps.CatalogueDashboardConfig):
        name = 'yourappsfolder.dashboard.catalogue'
© www.soinside.com 2019 - 2024. All rights reserved.