0
我有相关的有两种型号:获得从相关模型的所有项目在Django
class Author(models.Model):
----
class Article(models.Model):
author = models.ForeignKey(Author)
....
我有类作者的一个实例。我如何获得作者的所有文章?如:
articles = author.article_set.getAllArticlesFromAuthor()
我知道它可以从查询得到,但我想知道是否存在由Django的
提供
我不明白你在问什么;那是article_set已经是什么了。只要做'author.article_set.all()'。 –
我阅读了文档,但没有找到它。 https://docs.djangoproject.com/en/1.10/ref/models/relations/ –