Django python manage.py runserver - 未处理的异常

时间:2016-05-08 15:59:39

标签: python django exception

我想开始学习Django框架,但我已经遇到了问题。我已经设置了Django和一切,但是当我到达运行服务器时,我的问题已经开始了。在我编写python manage.py runserver之后:

C:\Users\Programiranje\Desktop\Django\mysite> python manage.py runserver

它会抛出这样的异常:

Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.  
Run 'python manage.py migrate' to apply them. May 08, 2016 - 17:47:21 Django version 1.9.6, using settings 'mysite.settings'                        
Starting development server at http://127.0.0.1:8000/ 
Quit the server with CTRL-BREAK. 

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000000044E3488>
Traceback (most recent call last):   
File "C:\Python34\lib\site-packages\django-1.9.6py3.4.egg\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)   File "C:\Python34\lib\site-packages\django-1.9.6-py3.4.egg\django\core\management\commands\runserver.py", line 137, in  inner_run
    ipv6=self.use_ipv6, threading=threading)   File "C:\Python34\lib\site-packages\django-1.9.6-py3.4.egg\django\core\servers\basehttp.py", line 188, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)   File "C:\Python34\lib\site-packages\django-1.9.6-py3.4.egg\django\core\servers\basehttp.py", line 73, in __init__
    super(WSGIServer, self).__init__(*args, **kwargs)   File "C:\Python34\lib\socketserver.py", line 430, in __init__
    self.server_bind()   File "C:\Python34\lib\site-packages\django-1.9.6-py3.4.egg\django\core\servers\basehttp.py", line 77, in server_bind
    super(WSGIServer, self).server_bind()   File "C:\Python34\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)   File "C:\Python34\lib\http\server.py", line 135, in server_bind
    self.server_name = socket.getfqdn(host)   File "C:\Python34\lib\socket.py", line 463, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 0: invalid start byte

我真的很感激任何帮助!

4 个答案:

答案 0 :(得分:1)

解决方案:确保您的计算机名称来自ASCII表格中的字符:)

答案 1 :(得分:1)

我有一个类似但却没那么有帮助的错误信息:

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x00000000051F2518>

(提供零追溯)

这是由于我的某个应用迁移文件夹中存在合并迁移引起的,这些迁移文件夹引用了不存在的迁移。迁移引用了来自另一个VCS分支的其他迁移,并且是由同事意外提交的,我已将其合并到我的分支中。

在此发布答案,因为这是有关此主题的最明显的问题。

答案 2 :(得分:0)

我遇到了类似的问题,这是因为我使用的是django的旧版本。 如果您使用的是Mac,请运行以下命令:

1。删除当前的django版本并安装最新的稳定版本。

pip3 install -U django 

2。应用迁移(如果有)。确保在您的项目目录中运行此命令。

python3 manage.py migrate

3。在本地端口8000上启动服务器。

python3 manage.py runserver

干杯!

答案 3 :(得分:-2)

如错误所示,您尚未应用迁移。 只需运行python manage.py migrate即可。这就足够了。