How to register a new Model in Django-Oscar Dashbo

2020-05-06 08:23发布

问题:

I forked catalogue app and added a new model in the new app's models.py

class BundleProductClass(Product):
    products = models.ManyToManyField(Product, related_name="bundle_products")

    class Meta:
        verbose_name = 'Bundle Product'

In admin.py registered the new model admin.site.register(BundleProductClass)

I can see the new model in /admin url but in /dashboard it is not registered. What do I have to do to register it in dashboard view?

回答1:

The Oscar dashboard is not linked to the Django admin.

If you want to manage a model through the Oscar dashboard, you have to create your own views and add them to the dashboard navigation.



回答2:

Changing the forked app admin.py worked for me

#catalogue/admin.py
from oscar.apps.catalogue.admin import *  # noqa
from modapps.catalogue.models import Brand

class BrandAdmin(admin.ModelAdmin):
    list_display = [ 'id']


admin.site.register(Brand, BrandAdmin)