在本地WiFi网络上提供Django项目 [英] Serve Django project on local WiFi Network

查看:127
本文介绍了在本地WiFi网络上提供Django项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

python manage runserver 0.0.0.0:8000

启动服务器,以便我可以从我的wifi网络上的其他计算机访问该项目,但是当我浏览到另一台计算机上的internet-ipaddress:8000时,该项目不加载。我错过了一个设置?

to start the server so that I can access the project from other computers on my wifi network, but when i browse to internet-ipaddress:8000 on an another computer, the project doesn't load. Am I missing a setting?

推荐答案

假设所有的机器都可以看到彼此...

Assuming all the machines can see eachother ...

获取运行runserver的机器的IP地址。例如,在控制台运行 ifconfig

get the IP address of the machine you are running runserver on. For example run ifconfig at the console.

ifconfig

eth0      Link encap:Ethernet  HWaddr 10:1e:72:b8:2a:4b  
              inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
              ...

检查您是否正在运行防火墙。例如

check if you are running a firewall. For example

sudo ufw status

如果活动,您需要打开端口8000,再次在控制台运行

if active, you need to open port 8000 so, again at the console, run

sudo ufw allow 8000/tcp

然后启动runserver(或runserver_plus如果使用django-extensions)

then start the runserver (or runserver_plus if using django-extensions)

python manage.py runserver_plus 192.168.1.2:8000

在另一台机器上打开浏览器

open a browser on another machine

http://192.168.1.2:8000/admin

这篇关于在本地WiFi网络上提供Django项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆