Django运行访问项目出现的问题:DisallowedHost at / Invalid HTTP_HOST header:
DisallowedHost at /
Invalid HTTP_HOST header: '10.211.55.6:8000'. You may need to add u'10.211.55.6' to ALLOWED_HOSTS.
Request Method: | GET |
---|---|
Request URL: | http://10.211.55.6:8000/ |
Django Version: | 1.10.4 |
Exception Type: | DisallowedHost |
Exception Value: |
Invalid HTTP_HOST header: '10.211.55.6:8000'. You may need to add u'10.211.55.6' to ALLOWED_HOSTS. |
Exception Location: | /usr/lib/python2.7/site-packages/django/http/request.py in get_host, line 113 |
Python Executable: | /usr/bin/python |
Python Version: |
1,以上时我访问请求的时候出现的,原因在于Django框架中的创建的一个项目的时候,
2,跑下这个命令:python manage.py runserver 10.211.55.5:8000
3,然后在我本机的浏览器中写入上述IP和端口请求过去:http://10.211.55.6:8000
4,于是就出现了最上面的那个问题;
5,于是就去django-admin.py startproject project-name创建的项目中去修改 setting.py 文件:
ALLOWED_HOSTS = [‘*’] #在这里请求的host添加了*
6,于是就成功的访问到了Django的项目了;