Django不允许主机错误

时间:2018-02-15 18:01:06

标签: python django

这是我在浏览器中访问127.0.0.1:8000时遇到的错误

DisallowedHost at /

Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add '127.0.0.1' to ALLOWED_HOSTS.

Request Method:     GET
Request URL:    http://127.0.0.1:8000/
Django Version:     2.0.2
Exception Type:     DisallowedHost
Exception Value:    

Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add '127.0.0.1' to ALLOWED_HOSTS.

在你对我大吼大叫并告诉你应该在settings.py的ALLOWED_HOSTS字段中添加它之前,我已经按照Why is Django throwing error "DisallowedHost at /"?指示了。

Settings.py字段(我知道如果我放*那么其他一切都是多余的,但它仍然给我同样的错误。

ALLOWED_HOSTS = ['*','0.0.0.0','127.0.0.1']

这是我的wsgi.py文件

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wordtutor.settings")
# Uncommenting following also does not solve the error
#os.environ["DJANGO_SETTINGS_MODULE"] =  "wordtutor.settings"
application = get_wsgi_application()

我该如何解决这个问题?

编辑: Python3.6 Django 2

0 个答案:

没有答案