Reprinted from: https://www.cnblogs.com/areyouready/p/9029075.html https://jackyu.cn/tech/access-django-website-in-intranet/
django allow external access
The default method to start django
The first point: you need in a document in accordance with the following settings setting.py:
allowed_hosts = [ "*"]
He said the limited access, for example, I fill a ip, 192.168.1.1; then I will only allow the ip access to my site; also may not fully qualified, such as 192.168.1. *; Can also be a domain name "sb .com ", it would match the suffix" sb.com "domain name;
Second, and very importantly, be sure to turn off your firewall;
The third point, your server-start up, must be in 0.0.0.0:8000
In this way, your colleagues can through your computer's ip address and the corresponding routing, to access your project a
---------------------
Author: Butter cat
Source : CSDN
original: https: //blog.csdn.net/miantian180/article/details/79556848
copyright: This article is a blogger original article, reproduced, please attach Bowen link!
1 Turn off the firewall
service iptables stop
- 1
2 Set django
开开启django时,使用0.0.0.0:xxxx,作为ip和端口例如: python manage.py runserver 0.0.0.0:9000 然后在settings里修改ALLOWED_HOSTS = [], 改为ALLOWED_HOSTS = ['*',],注意不要漏掉“,”。 其他机器就可以通过这台机器的ip和端口号访问django了。 例如:http://192.168.14.40:9000/index.html
Django LAN access
Bloggers recently developed DCRMv4, related to the mobile version of front-end development work, due to the effect on the computer or on the phone with a little different, so they need access through the network to a "real machine debugging."
First, in settings.py project, joining the LAN IP address of the machine (if loaded end of the main words separated by commas, not divided, then, Django will not error)
Then stop ./manage.py runserver
Re-use ./manage.py runserver 0.0.0.0:8000
to start the server
Use PyCharm development, need
The Host changed 0.0.0.0
If your Mac, open the firewall, for use brew Python installed, there will be prompt Python need to allow incoming connections window pops up, please allow, if pop up, then again, you need to add a firewall in the white list of the current drive Django Python, if you still have pop-up warning every time you save it, you need to reinstall Python, when the output terminal as a result, you can open the phone for testing.
The default method to start django
第一点:需要在你的setting.py文件中将按照如下设置:
ALLOWED_HOSTS = ["*"]
他表示所限定的访问,比如我填写一个ip,192.168.1.1;那么我就只允许该ip对我的网站访问;也可以是不完全限定,如192.168.1.*;还可以是域名“sb.com”,那么它将匹配后缀为"sb.com"的域名;
第二点,也是很重要的一点,一定要关闭你的防火墙;
第三点,将你的服务器启动器起来,必须是在0.0.0.0:8000
这样,你的同事就可以通过你电脑的ip地址以及相应的路由,来访问你的项目了
---------------------
作者:黄油猫
来源:CSDN
原文:https://blog.csdn.net/miantian180/article/details/79556848
版权声明:本文为博主原创文章,转载请附上博文链接!
1关闭防火墙
service iptables stop
- 1
2设置django
开开启django时,使用0.0.0.0:xxxx,作为ip和端口例如: python manage.py runserver 0.0.0.0:9000 然后在settings里修改ALLOWED_HOSTS = [], 改为ALLOWED_HOSTS = ['*',],注意不要漏掉“,”。 其他机器就可以通过这台机器的ip和端口号访问django了。 例如:http://192.168.14.40:9000/index.html
Django 局域网内访问
博主最近在开发 DCRMv4,涉及到手机版前端开发工作,由于在电脑上的效果还是与手机上有些不同,所以需要通过内网访问的方式来进行“真机调试”。
首先,在项目的 settings.py 中,加入本机的局域网 IP 地址(如果加载末尾的话主要逗号分隔,不分割的话,Django 也不会报错)
然后停止 ./manage.py runserver
重新使用 ./manage.py runserver 0.0.0.0:8000
来启动服务器
使用 PyCharm 进行开发,需要在
将 Host 改为 0.0.0.0
If your Mac, open the firewall, for use brew Python installed, there will be prompt Python need to allow incoming connections window pops up, please allow, if pop up, then again, you need to add a firewall in the white list of the current drive Django Python, if you still have pop-up warning every time you save it, you need to reinstall Python, when the output terminal as a result, you can open the phone for testing.