我有一個模型老師有一個字段屬性。該屬性由一些預定義的選項填充。希臘的Unicode字符Django和管理後端
model.py
#-*-coding" utf-8 -*-
field_options=[
('Greek letters', 'Greek letters'),
('Greek letters', 'Greek letters'),
('Greek letters', 'Greek letters'),
('Greek letters', 'Greek letters'),
]
class Teacher(models.Model):
#fields here.....
field = models.CharField(choices=field_options, max_length=20)
通過現場我的意思是一個老師可以是一個數學家一個physicst等,但我存儲這些字段的希臘字。當我去django的管理員後端存儲一名老師時,我使用希臘字母作爲他姓氏的老師姓名他的地址等我選擇了一個選項爲他的領域,但當我點擊保存它給了我一個錯誤,價值的字段不是一個有效的選擇,讓我當值的字段像
u'\u039c\u0391\u0398.... etc
unicode的represantation爲什麼它保存在其他領域的其他希臘字母(姓氏名字等),而不是特定的一個?我能做些什麼來解決這個問題?
編輯:控制檯給我下面的錯誤。
/usr/local/lib/python2-7/dist-packages/django/db/models/fields/__init__.py:194:
UnicodeWarning:Unicode equal comparison failed to convert both arguments to Unicode -interpreting them as being unequal
elif value == option_key
還有一想....我改變了它syncdb.First後,它只是一個CharField沒有選擇,我手動添加它(無南).Could是這樣的錯嗎?
怎麼來的? –