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,210
  • 1
  • 24
  • 31
Sidharth Samant
  • 578
  • 6
  • 24

1 Answers1

6

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,210
  • 1
  • 24
  • 31