Skip to main content
 首页 » 编程设计

android之通过局域网访问django localhost服务器

2025年05月04日21pander-it

我的 PC 上运行着一个 Django 服务器。我想通过我的 android 手机访问服务器。我该怎么做?我试过运行

python manage.py runserver 0.0.0.0:8000.

在此之后,我可以通过电脑的 ip 地址从我的电脑访问服务器,但不能通过连接到同一 wifi 的其他设备访问。

请您参考如下方法:

你需要做这些步骤

1. run python manage.py runserver 0.0.0.0:8000 
2. figure out your ip address which is say 192.168.1.8 
3. Add '192.168.1.8' to ALLOWED_HOSTS list in your settings.py file. 
4. access 192.168.1.8:8000 on mobile. 

我试过了,它对我有用。