我有一个要在本地运行的Django应用程序。我在使用Python 3.7的win32上运行。我在Windows的“命令提示符”中输入以下内容:
$ python manage.py runserver
Django version 2.07, using settings 'web.settings'
Starting development server at http://127.0.0.1:8000
Quit the server with CTRL-BREAK.
在浏览器中打开localhost:8000 /时出现问题。发生什么事,我将在命令提示符中收到此错误:
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Program Files\Python37\lib\wsgiref\handlers.py", line 180, in finish_response()
self.write(data)
File "C:\Programs Files\Python37\lib\wsgiref\handlers.py", line 279, in write
self.write(data)
File "C:\Programs Files\Python37\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Programs Files\Python37\lib\socketserver.py", line 796, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
我不确定如何消除此错误。
答案 0 :(得分:1)
您已经设置了使用相同语言的查询和数据库。但是,尽管数据库使用的代码页包含850个可能的字符,但您的会话却具有1252个可能的字符。当两者尝试进行通信时,查询和数据库之间存在无法匹配的符号。
cmd.exe / c chcp 1252->将查询语言设置为1252个可能的字符== db(1252个可能的字符),从而解决了该问题。
答案 1 :(得分:0)
如果您在Windows上使用PostgreSQL,则可能会遇到代码页问题。
>psql -U postgres
psql (9.6)
WARNING: Console code page (850) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
postgres=#
在启动Django之前,请尝试设置代码页。
> cmd.exe /c chcp 1252