1.以一对多或者多对多的字段来查询,可能单个实例查询出多个重复的实例,用distinct去重即可
In [3]: DiaLogEvent.objects.filter(dialogchannel__channel__pindao_id__in=(2,))
Out[3]: <QuerySet [<DiaLogEvent: 12>, <DiaLogEvent: 12>]>
In [4]: DiaLogEvent.objects.filter(dialogchannel__channel__pindao_id__in=(2,)).distinct()
Out[4]: <QuerySet [<DiaLogEvent: 12>]>