说我是部落首领,俯瞰部落活动。我有 3 个模型:
class Hunter:
tribes = models.ManyToManyField(Tribe)
info
class Missions:
user = models.ForeignKey(User)
info
class Tribe:
tribe_chief = models.ForeignKey(User) #directed towards Chief
info
作为主管,我有 views.py(tribepk 通过 URL 传递)
user = request.user
tribe_instance = Tribe.objects.get(pk=tribepk)
myhunters = tribe_instance.hunter_set.all()
allmissions = Mission.objects.filter(user__in=myhunters)
因此,除了所有任务之外,所有内容都会填充。是否可以使用 _set.all() 结果作为过滤条件?谢谢
如果有帮助,这就是 myhunters 返回的内容 ->
'myhunters': [<Hunter: test>, <Hunter: asdf>, <Hunter: more>]