Python ';发生服务器错误。请与管理员联系;在django 1.8.11

Python ';发生服务器错误。请与管理员联系;在django 1.8.11,python,django,python-2.7,server,django-rest-framework,Python,Django,Python 2.7,Server,Django Rest Framework,我将django从1.7更新到1.8,我的服务器不再运行 我所做的: 尝试安装Python3.6:运行安装程序后,什么也没有发生 卸载Django 1.7并安装1.9。不幸的是,这个版本给我带来了麻烦(服务器甚至没有启动) 已卸载1.9并已安装1.8。现在它得到了这个错误 我在macOS Sierra上。10.12.3. 我的python版本是2.7 我需要Django的1.8版,以便使用“from rest\u framwork.view import-APIView” 有人能帮我吗 这是

我将django从1.7更新到1.8,我的服务器不再运行

我所做的:

  • 尝试安装Python3.6:运行安装程序后,什么也没有发生
  • 卸载Django 1.7并安装1.9。不幸的是,这个版本给我带来了麻烦(服务器甚至没有启动)
  • 已卸载1.9并已安装1.8。现在它得到了这个错误
我在macOS Sierra上。10.12.3. 我的python版本是2.7

我需要Django的1.8版,以便使用“from rest\u framwork.view import-APIView”

有人能帮我吗

这是日志:

    System check identified no issues (0 silenced).
    April 09, 2017 - 01:35:43
    Django version 1.8.18, using settings 'connectedin.settings'
    Starting development server at http://192.168.0.101:8000/
    Quit the server with CONTROL-C.
    Traceback (most recent call last):
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
        self.result = application(self.environ, self.start_response)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/contrib/staticfiles/handlers.py", line 63, in __call__
        return self.application(environ, start_response)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/core/handlers/wsgi.py", line 189, in __call__
        response = self.get_response(request)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/core/handlers/base.py", line 207, in get_response
        return debug.technical_500_response(request, *sys.exc_info(), status_code=400)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/views/debug.py", line 97, in technical_500_response
        html = reporter.get_traceback_html()
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/views/debug.py", line 384, in get_traceback_html
        return t.render(c)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 210, in render
        return self._render(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 202, in _render
        return self.nodelist.render(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 905, in render
        bit = self.render_node(node, context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/debug.py", line 79, in render_node
        return node.render(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/defaulttags.py", line 329, in render
        return nodelist.render(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 905, in render
        bit = self.render_node(node, context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/debug.py", line 79, in render_node
        return node.render(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/debug.py", line 89, in render
        output = self.filter_expression.resolve(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 648, in resolve
        obj = self.var.resolve(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 789, in resolve
        value = self._resolve_lookup(context)
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/template/base.py", line 849, in _resolve_lookup
        current = current()
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/http/request.py", line 152, in build_absolute_uri
        host=self.get_host(),
      File "/Library/Python/2.7/site-packages/Django-1.8.18-py2.7.egg/django/http/request.py", line 102, in get_host
        raise DisallowedHost(msg)
    DisallowedHost: Invalid HTTP_HOST header: '192.168.0.101:8000'. You may need to add u'192.168.0.101' to ALLOWED_HOSTS.
    [09/Apr/2017 01:35:51] "GET / HTTP/1.1" 500 59
看来你需要

这种行为在django 1.7]和django 1.8之间发生了变化

:

当调试为True或运行测试时,主机验证被禁用; 任何主人都可以接受。因此,通常只需要设置它 在生产中

:

当DEBUG为True且ALLOWED_HOSTS为空时,将验证该主机 针对['localhost','127.0.0.1','[::1]]

您需要将此IP地址添加到此设置中

关于以下内容:

ALLOWED_HOSTS = ['192.168.0.101', 'localhost', '127.0.0.1', '[::1]']
看来你需要

这种行为在django 1.7]和django 1.8之间发生了变化

:

当调试为True或运行测试时,主机验证被禁用; 任何主人都可以接受。因此,通常只需要设置它 在生产中

:

当DEBUG为True且ALLOWED_HOSTS为空时,将验证该主机 针对['localhost','127.0.0.1','[::1]]

您需要将此IP地址添加到此设置中

关于以下内容:

ALLOWED_HOSTS = ['192.168.0.101', 'localhost', '127.0.0.1', '[::1]']