从其他电脑访问Django应用程序 [英] Access Django app from other computers

查看:244
本文介绍了从其他电脑访问Django应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



现在我想让我的网络应用程序可以访问我的网络上的其他计算机。我们有一个共同的网络驱动器F:/。我应该将我的文件放在这个驱动器上,或者我可以在命令提示符下写python manage.py runserver test_my_app:8000,让网络中的其他计算机通过在浏览器中编写test_my_app:8000来访问Web服务器地址栏?我必须打开任何端口,我该怎么做?

解决方案

应该用中央系统或服务器完成。



默认情况下, manage.py runserver 不会给予ip bind权限。所以


请注意,默认IP地址127.0.0.1无法从您网络上的其他计算机访问。要使您的开发服务器可以查看网络上的其他计算机,请使用自己的IP地址(例如192.168.2.1)或0.0.0.0或::(启用IPv6)。


如果要检入本地机器,请按照


python manage.py runserver 0.0。 0.0:8000


现在转到您的网络计算机并访问您的IP,如 192.168.1.24:8000



更新:



对于Django版本约1.10应将您的主机添加到ALLOWED_HOSTS 此处


I am developing a web application on my local computer in Django.

Now I want my webapp to be accessible to other computers on my network. We have a common network drive "F:/". Should I place my files on this drive or can I just write something like "python manage.py runserver test_my_app:8000" in the command prompt to let other computers in the network access the web server by writing "test_my_app:8000" in the browser address field? Do I have to open any ports and how can I do this?

解决方案

It is should be done with central system or server.

By default manage.py runserver will not give ip bind permission. So

Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).

If you want to check in your local machine then follow

python manage.py runserver 0.0.0.0:8000

Now go to your network computer and access your ip like 192.168.1.24:8000

Updated:

For Django version about 1.10 you should add your host to ALLOWED_HOSTS here

这篇关于从其他电脑访问Django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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