Django升级1.9.6出现的中文本地化bug
Error日志:
- Error opening file for reading: Permission denied
- ERROR Internal Server Error: /
- Traceback (most recent call last):
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 174, in get_response
- response = self.process_exception_by_middleware(e, request)
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 172, in get_response
- response = response.render()
- File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 160, in render
- self.content = self.rendered_content
- File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 137, in rendered_content
- content = template.render(context, self._request)
- File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py", line 95, in render
- return self.template.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 206, in render
- return self._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 173, in render
- return compiled_parent._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 69, in render
- result = block.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/library.py", line 243, in render
- return t.render(new_context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 208, in render
- return self._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 220, in render
- nodelist.append(node.render_annotated(context))
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 1043, in render
- output = self.filter_expression.resolve(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 736, in resolve
- new_obj = func(obj, *arg_vals)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 51, in _dec
- return func(*args, **kwargs)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 278, in truncatechars
- return Truncator(value).chars(length)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 194, in wrapper
- return func(*args, **kwargs)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/text.py", line 103, in chars
- for char in self.add_truncation_text('', truncate):
- File "/usr/local/lib/python2.7/dist-packages/django/utils/text.py", line 77, in add_truncation_text
- '%(truncated_text)s...')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 93, in pgettext
- return _trans.pgettext(context, message)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 326, in pgettext
- result = ugettext(msg_with_ctxt)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 321, in ugettext
- return do_translate(message, 'ugettext')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 298, in do_translate
- _default = _default or translation(settings.LANGUAGE_CODE)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 205, in translation
- _translations[language] = DjangoTranslation(language)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 118, in __init__
- raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
- IOError: No translation files found for default language zh-CN.
- Traceback (most recent call last):
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 177, in __call__
- response = self.get_response(request)
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 230, in get_response
- response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 284, in handle_uncaught_exception
- 'request': request
- File "/usr/lib/python2.7/logging/__init__.py", line 1166, in error
- self._log(ERROR, msg, args, **kwargs)
- File "/usr/lib/python2.7/logging/__init__.py", line 1258, in _log
- self.handle(record)
- File "/usr/lib/python2.7/logging/__init__.py", line 1268, in handle
- self.callHandlers(record)
- File "/usr/lib/python2.7/logging/__init__.py", line 1308, in callHandlers
- hdlr.handle(record)
- File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
- self.emit(record)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/log.py", line 115, in emit
- message = "%s\n\n%s" % (self.format(no_exc_record), reporter.get_traceback_text())
- File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 323, in get_traceback_text
- return t.render(c)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 206, in render
- return self._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 1043, in render
- output = self.filter_expression.resolve(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 736, in resolve
- new_obj = func(obj, *arg_vals)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 778, in date
- return formats.date_format(value, arg)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/formats.py", line 151, in date_format
- return dateformat.format(value, get_format(format or 'DATE_FORMAT', use_l10n=use_l10n))
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 367, in format
- return df.format(format_string)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 37, in format
- pieces.append(force_text(getattr(self, piece)()))
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 292, in r
- return self.format('D, j M Y H:i:s O')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 37, in format
- pieces.append(force_text(getattr(self, piece)()))
- File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 78, in force_text
- s = six.text_type(s)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 114, in __text_cast
- return func(*self.__args, **self.__kw)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 85, in ugettext
- return _trans.ugettext(message)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 321, in ugettext
- return do_translate(message, 'ugettext')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 298, in do_translate
- _default = _default or translation(settings.LANGUAGE_CODE)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 205, in translation
- _translations[language] = DjangoTranslation(language)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 118, in __init__
- raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
- IOError: No translation files found for default language zh-CN.
- [pid: 3318|app: 0|req: 1/1] 219.237.242.144 () {44 vars in 5238 bytes} [Fri May 6 10:19:53 2016] GET / => generated 0 bytes in 243 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
- Error opening file for reading: Permission denied
- [pid: 3321|app: 0|req: 1/2] 68.180.229.29 () {32 vars in 469 bytes} [Fri May 6 10:21:04 2016] GET /ge/qqt-a653480/ => generated 19272 bytes in 272 msecs (HTTP/1.1 200) 3 headers in 195 bytes (1 switches on core 0)
- Error opening file for reading: Permission denied
- ERROR Internal Server Error: /
- Traceback (most recent call last):
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 174, in get_response
- response = self.process_exception_by_middleware(e, request)
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 172, in get_response
- response = response.render()
- File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 160, in render
- self.content = self.rendered_content
- File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 137, in rendered_content
- content = template.render(context, self._request)
- File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py", line 95, in render
- return self.template.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 206, in render
- return self._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 173, in render
- return compiled_parent._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 69, in render
- result = block.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/library.py", line 243, in render
- return t.render(new_context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 208, in render
- return self._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 220, in render
- nodelist.append(node.render_annotated(context))
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 1043, in render
- output = self.filter_expression.resolve(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 736, in resolve
- new_obj = func(obj, *arg_vals)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 51, in _dec
- return func(*args, **kwargs)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 278, in truncatechars
- return Truncator(value).chars(length)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 194, in wrapper
- return func(*args, **kwargs)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/text.py", line 103, in chars
- for char in self.add_truncation_text('', truncate):
- File "/usr/local/lib/python2.7/dist-packages/django/utils/text.py", line 77, in add_truncation_text
- '%(truncated_text)s...')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 93, in pgettext
- return _trans.pgettext(context, message)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 326, in pgettext
- result = ugettext(msg_with_ctxt)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 321, in ugettext
- return do_translate(message, 'ugettext')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 298, in do_translate
- _default = _default or translation(settings.LANGUAGE_CODE)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 205, in translation
- _translations[language] = DjangoTranslation(language)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 118, in __init__
- raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
- IOError: No translation files found for default language zh-CN.
- Traceback (most recent call last):
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 177, in __call__
- response = self.get_response(request)
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 230, in get_response
- response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
- File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 284, in handle_uncaught_exception
- 'request': request
- File "/usr/lib/python2.7/logging/__init__.py", line 1166, in error
- self._log(ERROR, msg, args, **kwargs)
- File "/usr/lib/python2.7/logging/__init__.py", line 1258, in _log
- self.handle(record)
- File "/usr/lib/python2.7/logging/__init__.py", line 1268, in handle
- self.callHandlers(record)
- File "/usr/lib/python2.7/logging/__init__.py", line 1308, in callHandlers
- hdlr.handle(record)
- File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
- self.emit(record)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/log.py", line 115, in emit
- message = "%s\n\n%s" % (self.format(no_exc_record), reporter.get_traceback_text())
- File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 323, in get_traceback_text
- return t.render(c)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 206, in render
- return self._render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 197, in _render
- return self.nodelist.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 992, in render
- bit = node.render_annotated(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 959, in render_annotated
- return self.render(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 1043, in render
- output = self.filter_expression.resolve(context)
- File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 736, in resolve
- new_obj = func(obj, *arg_vals)
- File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 778, in date
- return formats.date_format(value, arg)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/formats.py", line 151, in date_format
- return dateformat.format(value, get_format(format or 'DATE_FORMAT', use_l10n=use_l10n))
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 367, in format
- return df.format(format_string)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 37, in format
- pieces.append(force_text(getattr(self, piece)()))
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 292, in r
- return self.format('D, j M Y H:i:s O')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 37, in format
- pieces.append(force_text(getattr(self, piece)()))
- File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 78, in force_text
- s = six.text_type(s)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 114, in __text_cast
- return func(*self.__args, **self.__kw)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 85, in ugettext
- return _trans.ugettext(message)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 321, in ugettext
- return do_translate(message, 'ugettext')
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 298, in do_translate
- _default = _default or translation(settings.LANGUAGE_CODE)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 205, in translation
- _translations[language] = DjangoTranslation(language)
- File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 118, in __init__
- raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
- IOError: No translation files found for default language zh-CN.
经确认是新版本的django包版本中只有zh_Hans目录,没有zh_CN,把zh_Hans目录复制一个zh_CN就Ok了
一楼评论的方法也不错,在settings里面直接改成zh-Hans,这样就不用升级完Django,还去改目录了。
Django升级1.9.6出现的中文本地化bug的更多相关文章
- django升级2.1python升级3.7时出现的错误:"trying to load '%s': %s" % (entry[1], e) django.template.library.InvalidTemplateLibrary:
django升级2.1python升级3.7时出现如下的错误: "trying to load '%s': %s" % (entry[1], e) django.template. ...
- Ubuntu中文本地化后字体改变
ubuntu中文本地化后会安装2个字体 fonts-arphic-ukai fonts-arphic-uming 找到这两个字体删除之.. sudo apt- get remove fonts-arp ...
- Laravel 验证中文本地化
1.使用bootsrap好看的提示样式 但是会提示英文 2.将提示中文本地化 2.1.在/resouce/lang下创建文件夹:zh 2.2.已经有小伙伴做好了翻译 https://gist.gith ...
- WSL中文本地化
WSL中文本地化 Windows Subsystem for Linux(简称WSL)是一个在Windows 10上能够运行原生Linux二进制可执行文件(ELF格式)的兼容层.它是由微软与Canon ...
- Django升级1.6之后出现“Bad Request (400)”错误的解决方案
Django从1.4升级到1.6之后发现之前的网站都无法访问了,会出现“Bad Request (400)”的错误,搜了半天终于找到了解决办法. 解决方法很简单: 在settings.py里面添加: ...
- 关于Django升级的一些联想
刚刚阅读完django1.11的release note,从django1.4一直用到django1.11,以及即将到来的大版本django2.0,Django的版本升级策略和国内的技术现状对比称得上 ...
- Django升级1.8的一些问题
1.最明显的问题当然是Settings设置中关于模板的设置数据结构发生变化,这个就不细说了,你开个Django的1.8的新项目就知道怎么改了 2.migrations问题,这个问题是1.8最主要的修改 ...
- Django学习手册 - admin后台 切换成中文显示/添加数据表
Django admin后台管理 切换成中文界面: 站点显示为中文: 在setting 里面修改 LANGUAGE_CORE = 'zh-Hans' 字段名显示中文 class Test(models ...
- django 使用HttpResponse返回json数据为中文
之前我用django一般用JsonResponse来返回json数据格式 但是发现返回中文的时候会乱码 from django.http import JsonResponse def test(re ...
随机推荐
- 记录最近的几个bug
记录最近出的几个bug connection reset by peer 最近服务器经常性的出现connection reset by peer的错误,开始我们只是以为小概率的网络断开导致的,可是随着 ...
- Android官方命令深入分析之hprof-conv
hprof-conv工具可以将Android SDK工具生成的HPROF文件生成一个标准的格式,这样你就可以使用工具进行查看: hprof-conv [-z] <infile> <o ...
- 安装配置Kafka
1,下载kafka安装包,解压缩,tar -zxvf kafka_2.10-0.8.2.1.tgz 2,修改/etc/profile文件,增加KAFKA_HOME变量 3,进入KAFKA_HOME/c ...
- 【Unity 3D 游戏开发】Unity3D 入门 - 工作区域介绍 与 入门示例
一. 工作区域详解 1. Scence视图 (场景设计面板) scence视图简介 : 展示创建的游戏对象, 可以对所有的游戏对象进行 移动, 操作 和 放置; -- 示例 : 创建一个球体, 控制摄 ...
- OJ题:奇偶归一猜想——求归一过程中的最大值
题目: 题目内容: 奇偶归一猜想--对于每一个正整数,如果它是奇数,则对它乘3再加1,如果它是偶数,则对它除以2,如此循环,最终都能够得到1. 如n = 11,得序列:11, 34, 17, 52, ...
- 10_Android中通过HttpUrlConnection访问网络,Handler和多线程使用,读取网络html代码并显示在界面上,ScrollView组件的使用
编写如下项目: 2 编写Android清单文件 <?xml version="1.0" encoding="utf-8"?> <mani ...
- 让你的动画不再生硬 Android插值器Interpolator使用秘籍
有木有厌烦生硬的动画效果,想不想让你的动画变得圆滑且 欢迎收看本期的走进科学... 停,停,别打了,(.﹏.*) 我错了-- 我们要达到的效果: 先来回顾一下普通动画的用法吧. * 缩放动画 Scal ...
- STL - queue(队列)
Queue简介 queue是队列容器,是一种"先进先出"的容器. queue是简单地装饰deque容器而成为另外的一种容器. #include <queue> queu ...
- jquery.query-*.js 操作url
做的项目中需要用到通过JS获取GET参数,上网找了一下,找到如下插件: 例如 当前你的URL是: http://www.xxx.com/index.php?test=1&kk=2 如果想 ...
- Java泛型type体系
最近看开源代码,看到里面很多Java泛型,并且通过反射去获取泛型信息.如果说要看懂泛型代码,那还是比较容易,但是如果要自己利用泛型写成漂亮巧妙的框架,那必须对泛型有足够的了解.所以这两三天就不在不断地 ...