1

This is a follow-up from this question. Although I can write a non-binary LIKE query such as - SELECT COUNT(*) FROM TABLE WHERE MID LIKE 'TEXT%' in raw SQL, I would like to know if it's possible through the Django ORM.

Both startswith and contains seem to be using a binary pattern search.

Endre Both
  • 5,540
  • 1
  • 26
  • 31
Sidharth Samant
  • 714
  • 8
  • 28

1 Answers1

7

Try istartswith and icontains, which in MySQL resolve to LIKE rather than LIKE BINARY.

Note that with MySQL, the case-sensitivity of the comparison depends on the collation set in the database (meaning that i lookups may still be case-sensitive!).

Endre Both
  • 5,540
  • 1
  • 26
  • 31