1.首先修改django系统的settings.py文件:
比如本机ip为192.168.0.1
ALLOWED_HOSTS = ['ip', 'localhost', '127.0.0.1']
所以应写成如下:
ALLOWED_HOSTS = ['192.168.0.1', 'localhost', '127.0.0.1']
2.本机命令行启动django程序:
python manage.py runserver 0.0.0.0:指定端口号port
如:
比如本机ip为192.168.0.1
ALLOWED_HOSTS = ['ip', 'localhost', '127.0.0.1']
所以应写成如下:
ALLOWED_HOSTS = ['192.168.0.1', 'localhost', '127.0.0.1']