将Django开发服务器设为公共网站 [英] Make Django development server a public website

查看:127
本文介绍了将Django开发服务器设为公共网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台运行Lion的Mac和一台D-link路由器DIR-601.我想将django开发服务器作为公共网站运行以进行测试.我通过端口8000将端口转发设置为计算机的本地IP地址.然后,输入路由器的IP地址(通过在浏览器中输入IP地址获得),然后输入:8000.没有.任何人都可以帮忙或指导我完成该任务的教程吗?

I have a mac running Lion, and a D-link router DIR-601. I want to run my django development server as a public website for testing. I set up port forwarding to my computers local ip address, through port 8000. Then i entered the ip address of my router (obtained by typing my ip address in a browser) followed by :8000. Nothing. Can any one assist or point me to a tutorial for accomplishing this?

推荐答案

尝试:

python manage.py runserver 0.0.0.0:8000

因为默认情况下runserver将绑定到地址127.0.0.1,其他计算机无法访问该地址.

Because runserver will bind to address 127.0.0.1 by default, which is not accessible by other computers.

并且不要忘记更改settings.py.您还必须配置ALLOWED_HOSTS.例如: ALLOWED_HOSTS = ['*']

And don't forget to change settings.py. You have to configure also ALLOWED_HOSTS. For example: ALLOWED_HOSTS = ['*']

这篇关于将Django开发服务器设为公共网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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