mingle
mingle

Reputation: 620

python django partial match regular expression

So i want to filter a queryset and get all objects that have a partial match to a word

queryset.filter(name=r'regex')

search term = app

I am really bad with regex any help would be greatly appreciated.

Upvotes: 4

Views: 6513

Answers (1)

knbk
knbk

Reputation: 53659

You don't need a regex for a partial match, use contains:

queryset.filter(name__contains='partial')

Or when you need a case-insensitive match:

queryset.filter(name__icontains='partial')

Upvotes: 10

Related Questions