from django.contrib import admin
from myblog.models import Category, Post


class CategoryInline(admin.TabularInline):
    model = Category.posts.through

class PostAdmin(admin.ModelAdmin):
    inlines = [CategoryInline,]

class CategoryAdmin(admin.ModelAdmin):
    inlines = [CategoryInline,]
    exclude = ('posts',)


admin.site.register(Post, PostAdmin)
admin.site.register(Category, CategoryAdmin)
