[Django]-Multiple Django Admin Arguments with Extensions

3👍

In python, class can have more than one parent. Just inherit from 2 parents at once. But both ImportExportModelAdmin and SimpleHistoryAdmin are inheriting from ModelAdmin, that’s not good. There is also ImportExportMixin, we can use it instead of ImportExportModelAdmin, so there will be only one reference to ModelAdmin.

class CarResource(resources.ModelResource):
    class Meta:
        model = Cars
        fields = ('id','Year', 'Make', 'Model',)

class CarAdmin(ImportExportMixin, SimpleHistoryAdmin):
    resource_class = CarResource
    pass

#I want to use the import/export extension (code above), along with simple-history
admin.site.register(Cars, CarAdmin)

Leave a comment