现有两张表,一张书籍表(Book),一张作者表(Author)
现在想查询出书本信息和书本的作者
book=Book.objects.get(name="python")
book.author_id.author book.外键
查询张三写了哪些书
方法一:
auth=Author.objects.fliter(name="张山").values(id)
au=Books.objects.filter(author_id=auth).values("name")
方法二:
auth=Author.objects.fliter(name="张山")[0]
auth.book_set.all() #关联book表