Search code examples
djangodjango-admin

Django Admin: show multiple apps together in one section?


I'm working on a Django API for a webshop, and I organized the models and views into different apps: one for orders, one for baskets, one for products, and one for offers. Now I want to add these models to the admin site, but I don't want it to show up as four different sections each with one model to manage. Instead I want a new "Shop" section where I show the models for all these apps.

So instead of this:

enter image description here

I want both models in one common section. Is this possible?

I tried setting the same verbose name in both app's apps.py file, but that just results in two sections with the same name:

enter image description here


Solution

  • You can use django-modeladmin-reorder [PyPI] for this. You can configure this with the ADMIN_REORDER setting:

    # settings.py
    
    INSTALLED_APPS = (
        # …,
        'admin_reorder',
        # …
    )
    
    # …
    
    MIDDLEWARE_CLASSES = (
        # …,
        'admin_reorder.middleware.ModelAdminReorder',
        # …
    )
    
    # …
    
    ADMIN_REORDER = (
        {'label': 'product', 'models': ('product.Product', 'order.Order')},
    )