使用 Jython 的 Django 开发服务器上的乱码输出
我在 Windows 7 上的 Jython (2.5.2) 上运行 Django (1.2.5)(也在 XP 上尝试过,得到相同的结果)。我遇到的问题是 Django 开发服务器。服务器输出的每一行的前几个字符都是乱码。
jython Manage.py runserver
验证模型...
发现 0 个错误
使用设置“Polls.settings”,在 Django 版本 1.2.5 中
开发服务器正在 http://127.0.0.1:8000/
运行 使用 CONTROL-C 退出服务器。
←[35;1m[2011年3月9日16:33:09]“GET / HTTP/1.1”500 64949
←[0m←[32m[09/3/2011 16:33:16] "GET /admin HTTP/1.1" 301 0
←[0m←[m[2011年3月9日16:33:17]“获取/admin/HTTP/1.1”200 1882
←[0m
问题是我实际上无法使用 Ctrl-C (或 Ctrl-Z 等)停止服务器。如果我尝试按 Ctrl-Break,我会得到看起来很长的堆栈跟踪,但服务器仍在运行。阻止它的唯一方法是完全关闭终端窗口。
仅当在 Jython 上运行 Django 时才会发生这种情况。在 CPython 上,没问题。
这也会在输入数据(例如设置管理员超级用户等)时导致问题。数据被损坏并且输入不正确。所以这似乎是一个字符编码问题。我用谷歌搜索了所有地方,但未能找到答案。我做错了什么,或者我需要做什么?谢谢。
I'm running Django (1.2.5) on Jython (2.5.2) on Windows 7 (have also tried this on XP with the same results). The problem I'm running into is with the Django development server. The output from the server is garbled in the first few characters of every line.
jython manage.py runserver
Validating models...
0 errors found
Django version 1.2.5, using settings 'Polls.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
←[35;1m[09/Mar/2011 16:33:09] "GET / HTTP/1.1" 500 64949
←[0m←[32m[09/Mar/2011 16:33:16] "GET /admin HTTP/1.1" 301 0
←[0m←[m[09/Mar/2011 16:33:17] "GET /admin/ HTTP/1.1" 200 1882
←[0m
The problem is I can't actually stop the server using Ctrl-C (or Ctrl-Z, etc.). If I try Ctrl-Break, I get what looks to be a very long stack trace, but the server is still running. The only way to stop it, is to close the terminal window entirely.
This only happens when running Django on Jython. On CPython, it's fine.
This also causes problems when entering data like setting the admin super user, etc. The data gets corrupted and is not entered correctly. So it seems to be a character encoding issue. I've googled all over the place and have not been able to find the answer. What am I doing wrong, or what do I need to do? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
DJANGO_COLORS
环境变量设置为nocolor
以禁用 Django 对输出着色的尝试。然后在 Django 错误跟踪器中记录错误。
Set the
DJANGO_COLORS
environment variable tonocolor
in order to disable Django's attempts to colorize the output.And then log a bug in the Django bug tracker.