Customize dashboard catalogue forms in Django Oscar doesn't work

只愿长相守 提交于 2020-04-18 05:48:17

问题


I have followed the main documentations for django oscar. and I am trying to add a new field to product named video_url.

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',
]

回答1:


your app.py file it has to be

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


   class CatalogueDashboardConfig(apps.CatalogueDashboardConfig):
        name = 'yourappsfolder.dashboard.catalogue'



回答2:


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.



来源:https://stackoverflow.com/questions/61177757/customize-dashboard-catalogue-forms-in-django-oscar-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!