自定义Django Oscar中的仪表板目录表格不起作用 [英] Customize dashboard catalogue forms in Django Oscar doesn't work
问题描述
我一直遵循django oscar的主要文档.并且我正在尝试将新字段添加到名为video_url的产品中.
I have followed the main documentations for django oscar. and I am trying to add a new field to product named video_url.
首先,我将新字段添加到产品模型中,并且效果很好. catalogue/models.py
first I add the new field to product models and it worked fine. 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 *
然后我继续自定义目录仪表板,但似乎它没有改变任何东西,没有错误或其他任何东西.
and then I continue to customize the catalogue dashboard but it seems like it didn't change any thing there's no error or anythin.
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',
]
推荐答案
您需要先派生核心仪表板应用程序( oscar.apps.dashboard
),然后才能派生任何子应用程序( oscar.apps.dashboard.catalogue
)-这就是动态加载当前无法正常工作的原因.
You need to fork the core dashboard app (oscar.apps.dashboard
) before you can fork any of it's sub-apps (oscar.apps.dashboard.catalogue
) - that's the reason the dynamic loading isn't working currently.
This note has been added to the documentation but hasn't made it onto readthedocs.com yet.
这篇关于自定义Django Oscar中的仪表板目录表格不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!