Ilia Korepanov
Ilia Korepanov

Reputation: 13

When inheriting from two classes, I have functionality from only one

When inheriting from two classes, in the admin panel I only have the functionality of the class that comes first. For example, it will only show entity shift (Django MPTT) or only the "Load data" button (DjangoObjectActions). Is there any way to have both functionalities? My code:

from django.contrib import admin
from mptt.admin import MPTTModelAdmin
from .models import Category, Image
from django_object_actions import DjangoObjectActions, action
from scripts.load_csv_to_db import run


class CategoryAdmin(MPTTModelAdmin, DjangoObjectActions):
    @action(label='Load data')
    def load_data(self, request, queryset):
        run()

    changelist_actions = ('load_data', )


admin.site.register(Category, CategoryAdmin)
admin.site.register(Image)

Thank you.

Upvotes: 1

Views: 35

Answers (0)

Related Questions