Zemogle
Zemogle

Reputation: 604

How to replicate the TabularInline from django admin in Wagtail admin

Say I have the classic Author and Book example from the Django docs

class Author(models.Model):
    name = models.CharField(max_length=100)


class Book(models.Model):
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)

In standard Django I can create Author instance and add their books with TabularInline e.g.

class BookInline(admin.TabularInline):
    model = Book


class AuthorAdmin(admin.ModelAdmin):
    inlines = [
        BookInline,
    ]

I have a Wagtail project where I want to replicate this but I'm stumped. I have created Author and Book as Snippets and I can use InlinePanel to link to Books but it is a much slower edit/creation process (particularly as I think you need to create Book instances before you link then in Author). Help!

Upvotes: 0

Views: 18

Answers (0)

Related Questions