Django queryset to match all related objects

后端 未结 3 1191
暗喜
暗喜 2021-01-13 18:14

Let\'s say I have a ForeignKey from Coconut to Swallow (ie, a swallow has carried many coconuts, but each coconut has been carried by only one swallow). Now let\'s say that

3条回答
  •  不要未来只要你来
    2021-01-13 18:27

    If i understood your altered question correctly you should be able to compare the coconut_carried_set of the swallow with the list of coconuts that have been carried.

    see docs

    I'm not entirely sure that this is what you want - I guess it depends on if you know which swallow you want to check beforehand or if you want to check it against all swallows - in that case there may be a better solution.

提交回复
热议问题