python - 我可以更改 Django 的 "Starting development server"链接吗?

标签 python django

当我启动正在开发的 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/

相关文章:

javascript - Django 中的 AJAX 渲染 JSON

python - int 的文字无效 - 从 CSV 文件获取原始数据

python - 捕获由 python 子进程创建的进程的运行时错误

python - post_save信号未调用

django - 给出初始值会在 django 中引发 'value for field is required' 错误

python - 通用外键或外键

python - Pyparsing 是否支持上下文相关语法?

python - 图像的线性组合给我错误

python - plotly vs seaborn : violin plot in python

python - 从 django.utils.importlib 导入 import_module 导入错误 : No module named importlib