Skip to content Skip to sidebar Skip to footer

Django: Can't Include The ManyToManyField Field Because Manually Specifies A 'through' Model

I googled many times and found only one solution to add custom intermediate model for two model having relation through 3rd model. And I applied as usual as suggested but still get

Solution 1:

You have to change the admin to include InlineModelAdmin objects

So, change

class AdminPost(admin.ModelAdmin):
    fieldsets = [
        (None, {'fields':['title', 'content', 'terms']})
    ]

to

class TermInlineAdmin(admin.TabularInline):
    model = Post.terms.through


class AdminPost(admin.ModelAdmin):
    fieldsets = [
        (None, {'fields':['title', 'content']})
    ]

    inlines = (TermInlineAdmin,)

Post a Comment for "Django: Can't Include The ManyToManyField Field Because Manually Specifies A 'through' Model"