0

I've two Admin classes for a single model:

from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin
from .models import *

class ProductSummernoteAdmin(SummernoteModelAdmin):
    summernote_fields = ('description',)

class ProductAdmin(admin.ModelAdmin):
    ...

admin.site.register(Product, ProductSummernoteAdmin)

I want to register both ProductSummernoteAdmin and ProductAdmin with Product model. How to do that? As, i can't register same model twice.

Shameer Kashif
  • 424
  • 3
  • 16
  • Does this answer your question? [Multiple ModelAdmins/views for same model in Django admin](https://stackoverflow.com/questions/2223375/multiple-modeladmins-views-for-same-model-in-django-admin) – JPG Oct 28 '20 at 13:07
  • That is using Proxy models. Is there any way without that? I read this one one, but the answer is too vague: https://stackoverflow.com/questions/54209583/django-admin-register-multiple-admin-classes-to-the-same-model – Shameer Kashif Oct 28 '20 at 13:10
  • Then the answer is a big No, You can't do that – JPG Oct 28 '20 at 13:23
  • Well, I found a bypass using multiple inheritance. Gonna add it as an answer. – Shameer Kashif Oct 28 '20 at 14:57

1 Answers1

1

I found a quick bypass for registering both SummernoteModelAdmin and admin.ModelAdmin classes using multiple inheritance without Proxy Models:

class ProductAdmin(SummernoteModelAdmin, admin.ModelAdmin):
    summernote_fields = ('description',)

    class Meta:
        model = Product

admin.site.register(Product, ProductAdmin)
Shameer Kashif
  • 424
  • 3
  • 16