創建好了Django,但是出現以下錯誤。
DisallowedHost at /
Invalid HTTP_HOST header: '101.201.155.148:8006'. You may need to add '101.201.155.148' to ALLOWED_HOSTS.
Request Method: GET
Request URL: http://101.201.155.148:8006/
Django Version: 3.1a1
Exception Type: DisallowedHost
Exception Value:
Invalid HTTP_HOST header: '101.201.155.148:8006'. You may need to add '101.201.155.148' to ALLOWED_HOSTS.
Exception Location: /usr/local/lib/python3.6/dist-packages/Django-3.1a1-py3.6.egg/django/http/request.py, line 137, in get_host
Python Executable: /usr/bin/python3
Python Version: 3.6.9
Python Path:
['/root/Detection',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/local/lib/python3.6/dist-packages/cloud_init-19.1.3-py3.6.egg',
'/usr/local/lib/python3.6/dist-packages/Django-3.1a1-py3.6.egg',
'/usr/local/lib/python3.6/dist-packages/sqlparse-0.3.1-py3.6.egg',
'/usr/local/lib/python3.6/dist-packages/pytz-2020.1-py3.6.egg',
'/usr/local/lib/python3.6/dist-packages/asgiref-3.2.7-py3.6.egg',
'/usr/lib/python3/dist-packages']
Server time: Wed, 17 Jun 2020 01:21:33 +0000
只需要修改settings.py文件中的允許所有站點訪問就行了。