wmoskal
wmoskal

Reputation: 295

Django Filter 'in' equivalent

I am looking to provide a user entered string to my model, to filter in a way similar to that of in in python. For Example, if I had a user entered string of 'Hello', and one of my model fields was called ComputerScience, and one of the values of Computer science was 'Hello World'. Is there any way that this can be achieved with a Django filter?

Upvotes: 1

Views: 48

Answers (1)

blhsing
blhsing

Reputation: 106552

You can use Django's built-in lookup contains:

MyModel.objects.filter(ComputerScience__contains='Hello')

Upvotes: 1

Related Questions