I have an object model. I also have a list of options for filtering the results. I'm not sure if there is an easy way to filter objects in the model so that any object that matches any of the elements in the filter list is returned. For instance:
usersWithPName = User.objects.filter(name__startswith = 'P')
filterList = ['P', 'T', 'R']
usersWithPTRName = User.objects.filter(name__startswith = filterList)
Is there a way to filter (in this case) the User model so that it returns an object that matches any of the elements in the filter list?
source
share