>>> p = Pet(kind="Кошка")
>>> p.kind
'xd0x9axd0xbexd1x88xd0xbaxd0xb0'
>>> p.save()
>>> Pet.objects.get(kind__iexact="кошка")
Traceback... # some traces
DoesNotExist: Pet matching query does not exist.
>>> p = Pet(kind="Cat")
>>> p.save()
>>> Pet.objects.get(kind__iexact="cat")
<Pet: Pet object>
或者有数据库级别的原因(我使用sqlite3(?
这不是Unicode。
p = Pet(kind=u"Кошка")
p.save()
print Pet.objects.get(kind__iexact=u"кошка")
重点在于sqlite3数据库本身,它不支持对非ASCII字符进行不区分大小写的搜索