>>> p = Pet(kind="Кошка")
>>> p.kind
'\xd0\x9a\xd0\xbe\xd1\x88\xd0\xba\xd0\xb0'
>>> p.save()
>>> Pet.objects.get(kind__iexact="кошка")
Traceback... # some traces
DoesNotExist: Pet matching query does not exist.
>&开发者_运维问答gt;> p = Pet(kind="Cat")
>>> p.save()
>>> Pet.objects.get(kind__iexact="cat")
<Pet: Pet object>
Or there are db-level reasons (i'm using sqlite3)?
That's not Unicode.
p = Pet(kind=u"Кошка")
p.save()
print Pet.objects.get(kind__iexact=u"кошка")
The point is in the sqlite3 database itself, it does not support case-insensitive search for non-ASCII characters
精彩评论