干净的 django 安装、运行服务器、回溯

clean django install, runserver, traceback

一直在关注 Coarsera 的 Python 专业化,并认为我会自己尝试一些东西!在开始之前我 运行 进入的第一件事是:

C:\Users\kurts\Python>django-admin startproject Kurtain

C:\Users\kurts\Python>cd kurtain

C:\Users\kurts\Python\Kurtain>manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
February 27, 2018 - 18:59:12
Django version 2.0.2, using settings 'Kurtain.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 0x00000296A6625048>
Traceback (most recent call last):
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\commands\runserver.py", line 143, in inner_run
    ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 163, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 66, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 453, in __init__
    self.server_bind()
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\http\server.py", line 138, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Users\kurts\AppData\Local\Programs\Python\Python36\lib\socket.py", line 673, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1: invalid start byte

从这里阅读其他问题,我认为安装的文件中缺少某些东西...?但即使在重新安装 django 之后,它还是同样的错误!

我在 windows10、python3.6 和 django2.0.2

上 运行

您没有应用迁移,因此您需要 运行 'python manage.py migrate'。 系统写信给你。

以上答案虽然正确,但不是解决方案。 我一直在关注 django 网站上的指南,它告诉我有关迁移的信息,我们将在后面的章节中处理。

但是我通过更改我的计算机名称设法解决了这个问题,它包含一个非 utf8 字符(我是瑞典人并且使用的是“ö”)。