1. 修改setting.py代碼
ALLOWED_HOSTS = ['*']
2. 啟動開發(fā)服務器
python manage.py runserver 0.0.0.0:8000
3. 查看電腦ip
(my_env) zzx@zzx:~/mysite$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 3426171 bytes 2898647356 (2.8 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3426171 bytes 2898647356 (2.8 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.43.206 netmask 255.255.255.0 broadcast 192.168.43.255
inet6 2408:84e1:4:fb94:92e:689f:dd87:5016 prefixlen 64 scopeid 0x0<global>
inet6 2408:84e1:4:fb94:c836:f37:3785:47d3 prefixlen 64 scopeid 0x0<global>
inet6 fe80::e7d8:4fac:248e:f2ae prefixlen 64 scopeid 0x20<link>
ether 20:79:18:fb:fc:c0 txqueuelen 1000 (Ethernet)
RX packets 3988145 bytes 5233469230 (5.2 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1877880 bytes 231731770 (231.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
得出ip地址為:192.168.43.206横浑。
4. 在手機上訪問項目
在手機上用瀏覽器打開:http://192.168.43.206:8000/blog
超棺,如下圖所示: