I have the following model classes:
class Category(models.Model):
category = models.CharField('category', max_length=200, blank=False)
class Book(models.Model):
title = models.CharField('title', max_length=200, blank=False)
categories = models.ManyToManyField(Category, blank=False, through='Book_Category')
class Book_Category(models.Model):
book = models.ForeignKey(Book)
category = models.ForeignKey(Category)
When adding a new book object in admin interface I would like to also add a new category, and book_category relationship.
If I include categories in BookAdmin as
class BookAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['categories', ]}), ...
I get can't include the ManyToManyField field 'categories' because 'categories' manually specifies a 'through' model
error.
Is there any way to achieve required functionality?