from django.contrib import admin from polymorphic.admin import ( PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter, ) from .models import CoursePayment, SchoolPayment, Payment class PaymentChildAdmin(PolymorphicChildModelAdmin): base_model = Payment show_in_index = True base_fieldsets = ( (None, {'fields': ('user', 'amount', 'status', 'data',)}), ) @admin.register(CoursePayment) class CoursePaymentAdmin(PaymentChildAdmin): base_model = CoursePayment @admin.register(SchoolPayment) class SchoolPaymentAdmin(PaymentChildAdmin): base_model = SchoolPayment @admin.register(Payment) class PaymentAdmin(PolymorphicParentModelAdmin): base_model = Payment polymorphic_list = True child_models = ( CoursePayment, SchoolPayment, )