Skip to content
Advertisement

There is a way to check if a model field contains a substring?

I wanted to know if I can do things like this:

full_string = "12345"
substring = "123"
Model.objects.filter.contains(field = substring)

More or less like this. In summary I want to search for a substring, not the string itself.

Advertisement

Answer

Take a look at Django contains and icontains

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement