我可以更改Django的“Starting development server”链接吗?

2024-09-24 04:20:59 发布

您现在位置:Python中文网/ 问答频道 /正文

当我启动开发中的Django站点时,我收到以下消息:

System check identified no issues (0 silenced).
August 15, 2017 - 12:03:00
Django version 1.11.3, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

只需单击提供的链接就可以了。但是,127.0.0.1不是我允许的主机之一,所以它不能工作。我可以设置或覆盖此消息以使其使用有效链接吗?在


Tags: djangono消息settingsserver站点链接version
1条回答
网友
1楼 · 发布于 2024-09-24 04:20:59

From the runserver documentation

django-admin runserver [addrport]

Starts a lightweight development Web server on the local machine. By default, the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an IP address and port number explicitly.

...

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).

You can provide an IPv6 address surrounded by brackets (e.g. [200a::1]:8000). This will automatically enable IPv6 support.

A hostname containing ASCII-only characters can also be used.

因此,您可以简单地使用:

./manage.py runserver localhost:8000

相关问题 更多 >