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/ –