1
假設,有一個列表django過濾器:可以過濾元組?
strings = ['a','b','c']
有兩種模式
class theModel:
theString = models.charField()
Class superModel:
hasClass = models.ForeignKey(theModel)
有什麼辦法來過濾用清單「theString」超級名模?
例如這可能是一個辦法(但有沒有更好的辦法,而不用於循環?)
tuple = []
for string in strings
tuple.append (theModel.objects.filter(theString = string))
result = []
for theModel in tuple
result.append (superModel.objects.filter(hasClass = theModel))
return result