[Django]-Django: how does manytomanyfield with through appear in admin?

93👍

You should use InlineModelAdmin. Docs.

class TeachSubjectInline(admin.TabularInline):
    model = TeachSubject
    extra = 2 # how many rows to show

class SchoolClassAdmin(admin.ModelAdmin):
    inlines = (TeachSubjectInline,)

admin.site.register(SchoolClass, SchoolClassAdmin)

Leave a comment