Reputation: 371
Suppose, there is a list
strings = ['a','b','c']
And There are two model
class theModel:
theString = models.charField()
Class superModel:
hasClass = models.ForeignKey(theModel)
Is there any way to filter superModel by 'theString' with list?
for example this can be one way ( but is there any better way? without for loop )
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
Upvotes: 1
Views: 1148