1from django.contrib import admin
2
3class BookInline(admin.TabularInline):
4 model = Book
5
6class AuthorAdmin(admin.ModelAdmin):
7 inlines = [
8 BookInline,
9 ]
10
1from django.db import models
2
3class Author(models.Model):
4 name = models.CharField(max_length=100)
5
6class Book(models.Model):
7 author = models.ForeignKey(Author, on_delete=models.CASCADE)
8 title = models.CharField(max_length=100)
9