2012-02-29 117 views
0

我想設置Django管理員顯示英文。這是我在settings文件中得到的。中國的Django管理員不工作

gettext = lambda s: s 
LANGUAGES = (
    ('zh-tw', gettext('Traditional Chinese')) 
) 

這是來自Official docs的示例。

然而,這是我收到的回溯:

環境:

請求方法:GET 請求URL:http://127.0.0.1:8000/admin/

Django Version: 1.3.1 
Python Version: 2.7.1 
Installed Applications: 
['django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.admin', 
'myapp'] 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.middleware.csrf.CsrfResponseMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'django.middleware.locale.LocaleMiddleware') 


Traceback: 
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response 
    89.      response = middleware_method(request) 
File "/Library/Python/2.7/site-packages/django/middleware/locale.py" in process_request 
    16.   language = translation.get_language_from_request(request) 
File "/Library/Python/2.7/site-packages/django/utils/translation/__init__.py" in get_language_from_request 
    124.  return _trans.get_language_from_request(request) 
File "/Library/Python/2.7/site-packages/django/utils/translation/trans_real.py" in get_language_from_request 
    369.  supported = dict(settings.LANGUAGES) 

Exception Type: ValueError at /admin/ 
Exception Value: dictionary update sequence element #0 has length 5; 2 is required 

現在看來,這是期待一個2字符串對於元組的第一個元素...但是在文檔中說它使用zh-tw,我真的很茫然......

回答

2

看起來像是一個缺失的逗號:

LANGUAGES = (
    ('zh-tw', gettext('Traditional Chinese')), # <= add a comma here 
)