Django多对多关联字段查询 Posted on 2018-07-06 Views: Disqus: 12345678class Author(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=40) email - models.EmailField()class Book(models.Model): title = models.CharField(max_length=200) authors = models.ManyToManyField(Author) 从Book角度查询Author:123book = Book.objects.get(id=1)book.authors.all() # 查询id为1的Book的所有Authorbook.authors.filter(first_name='jack') # 查询id为的Author中first_name为jack的Author 从Author角度查询Book:12author = Author.objects.get(id=1)author.book_set.all() # 查询id为1的Author的所有Book