django里的post_set是什么用法?
在一个Model下发现了类似ModelA.objects.get(xxx=xxx).post_set.defer(....),请问这里的post_set是一个什么用法?谢...
在一个Model下发现了类似ModelA.objects.get(xxx=xxx).post_set.defer(....),请问这里的post_set是一个什么用法?谢谢。我在django的文档里没有搜索到post_set。
展开
1个回答
展开全部
应该是有个叫post的model存在一个到ModelA的外键,自动为ModelA反向生成一个字段
Following relationships “backward”
If a model has a ForeignKey, instances of the foreign-key model will have access to a Manager that returns all instances of the first model. By default, this Manager is named FOO_set, where FOO is the source model name, lowercased. This Manager returns QuerySets, which can be filtered and manipulated as described in the “Retrieving objects” section above.
Following relationships “backward”
If a model has a ForeignKey, instances of the foreign-key model will have access to a Manager that returns all instances of the first model. By default, this Manager is named FOO_set, where FOO is the source model name, lowercased. This Manager returns QuerySets, which can be filtered and manipulated as described in the “Retrieving objects” section above.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |