假设有一个列表
strings = ['a','b','c']
并且有两种型号
class theModel:
theString = models.charField()
Class superModel:
hasClass = models.ForeignKey(theModel)
有没有办法通过'theString'和列表过滤superModel?
例如,这可能是一种方式(但有更好的方式吗?没有 for 循环)
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