>>> 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.
>>> p = Pet(kind="Cat")
>>> p.save()
>>> Pet.objects.get(kind__iexact="cat")
<Pet: Pet object>
或者有db级别的原因(我正在使用sqlite3)?
答案 0 :(得分:2)
那不是Unicode。
p = Pet(kind=u"Кошка")
p.save()
print Pet.objects.get(kind__iexact=u"кошка")