2013-11-28 14 views

回答

2

沒有更多的細節,你很難準確地確定哪些字段,但基本上你想要使用|運算符來組合兩個Q對象。

from django.db.models import Q 
result = SomeModel.objects.filter(Q(somefield='foo') | Q(somefield='bar')) 

見Q上的物體的全部細節的文檔: https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

+0

THX很多http://stackoverflow.com/users/2337736/peter-deglopper。你救了我的一天! – user956424

相關問題