Django应用无法从其他计算机打开

编程入门 行业动态 更新时间:2024-10-15 10:18:01
本文介绍了Django应用无法从其他计算机打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个运行在127.0.0.1:8000上的Django服务器

I have a Django server running on 127.0.0.1:8000

当我尝试从同一台计算机访问它时,便可以打开我的应用程序.但是,当我尝试使用machinename:8000从另一台计算机访问此应用程序时,它说无法访问此站点"

When I try to access it from the same machine then I am able to open my application. But when I try to access this app from a different machine by using machinename:8000 then it says 'This site can't be reached'

在我的settings.py中,我有

In my settings.py, I have

ALLOWED_HOSTS = config('ALLOWED_HOSTS',cast = Csv())

ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())

ALLOWED_HOSTS =

ALLOWED_HOSTS=

这与上面的配置有关吗?

Is this related to above configuration?

推荐答案

要与同一局域网中的其他计算机连接,必须使用以下命令运行服务器:

To connect with the other computers in the same local network as you you have to run your sever using :

manage.py runserver 0.0.0.0:8000

然后在您的settings.py中输入:

And in your settings.py put :

ALLOWED_HOSTS = ['*']

您必须知道您的PC的本地IP地址,并在最后添加:8000"进行连接.要了解您的计算机IP地址,请执行以下操作:重击:$ ifconfigWindows:ipconfig

And you have to know your local IP adress of your pc and connect adding ":8000" at the end. To know your computer IP adress: Bash : $ ifconfig Windows : ipconfig

更多推荐

Django应用无法从其他计算机打开

本文发布于:2023-10-07 13:14:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469481.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:其他计算机   Django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!