Display m2m field defined via 'through' in admin

后端 未结 1 1640
温柔的废话
温柔的废话 2021-02-09 10:15

I have the following model classes:

class Category(models.Model):
    category = models.CharField(\'category\', max_length=200, blank=False)

class Book(models.M         


        
1条回答
  •  难免孤独
    2021-02-09 10:52

    class CategoryInline(admin.TabularInline):
        model = Book_Category
        extra = 3 # choose any number
    
    class BookAdmin(admin.ModelAdmin):
        inlines = (CategoryInline,)
    
    admin.site.register(Book, BookAdmin)
    

    Docs

    0 讨论(0)
提交回复
热议问题