Suppose I have two users with username 'AbA' and 'aBa' in the database. My query word is 'ab'.
I used
User.objects.filter(username__contains='ab')
and
User.objects.filter(username__iexact='ab')
These two queries get empty result. However, I want to use something like username__contains__iexact='ab' that can retrieve both 'AbA' and 'aBa'.
username__contains__iexact='ab'
Anyone know how to resolve this problem? Thanks.
Use:
User.objects.filter(username__icontains='ab')
1.4m articles
1.4m replys
5 comments
57.0k users