- many author can write many books
# models..py
class Author(models.Model):
name = models.CharField(max_length=20)
class Book(models.Model):
title = models.CharField(max_length=20)
authors = models.ManyToManyField(Author
>>> from cbvApp.models import Author, Book
>>> a = Author(name='bob')
>>> a.save()
>>> b = Author(name='jack')
>>> b.save()
>>> a.book_set.create(title='the begins')
<Book: Book object (1)>
>>> b.book_set.create(title='the begins')
<Book: Book object (2)>
Author
+----+------+
| id | name |
+----+------+
| 1 | bob |
| 2 | jack |
+----+------+
Book
+----+------------+
| id | title |
+----+------------+
| 1 | the begins |
| 2 | the begins |
+----+------------+
book_authors
+----+---------+-----------+
| id | book_id | author_id |
+----+---------+-----------+
| 1 | 1 | 1 |
| 2 | 2 | 2 |
+----+---------+-----------+