[Answered ]-How to search CharField in Django?

2👍

I find answer by myself!

According to these links from django document:

Field lookups

iexact

If I use iexact:

>>> Blog.objects.get(name__iexact="beatles blog")

It would match a Blog titled “Beatles Blog”, “beatles blog”, or even “BeAtlES blOG”.

And the SQL equivalents:

SELECT ... WHERE name ILIKE 'beatles blog';

So, I can get I expect.

Leave a comment