class Article(models.Model):
title = models.Attribute()
tags = models.ListField(unicode)
new = Article(title='what ever')
new.tags = [ u'Niña', u'Niñb' ]
new.is_validate()
>>> True
new.save()
While when load:
Article.objects.all()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
In redis-cli:
redis 127.0.0.1:6379> GET "Article:tags:5omv5reh"
(error) ERR Operation against a key holding the wrong kind of value
So what's the reason that caused this?
So after trying, the unicode string should always be encode and saved as string. When get, always be decode. here comes the code:
When print: