当我启动正在开发的 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 不是我的 ALLOWED_HOSTS 之一,因此它不起作用。我可以设置或覆盖此消息,以便它使用有效的链接吗?
最佳答案
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
关于python - 我可以更改 Django 的 "Starting development server"链接吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45692586/