Zzz Zzz
Zzz Zzz

Reputation: 31

django database codec

I was trying to use some Chinese character in the sqlite database (with django), but can't be displayed in the admin page

From the setting.py:

LANGUAGE_CODE = 'en'

gettext = lambda s: s
LANGUAGES = (
    ('zh-cn', gettext('Simplified Chinese')),
    ('en', gettext('English')),
)

From the models.py: *'s Chinese characters

# -*- coding: cp936 -*-
class jiu(models.Model):
unit_list = (
        ('***', '***'),
        ('***', '***'),
    )
unit = models.CharField(max_length=8, choices=unit_list)

It's an sqlite3 database development server.

Upvotes: 1

Views: 89

Answers (1)

Paulo Scardine
Paulo Scardine

Reputation: 77251

If it is not Python 3 (I guess not, since I'm not aware Django has official support for py3k), you should use unicode literals:

unit_list = (
    (u'****', u'****'),
    (u'****', u'****'),
)

Upvotes: 1

Related Questions