本文介绍了django更改默认的runserver端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使默认端口 manage.py runserver 以无关紧要的 config.ini 。在 manage.py 中插入配置的端口之前,是否比解析 sys.argv 更容易一些?
I would like to make the default port that manage.py runserver listens on specifiable in an extraneous config.ini. Is there an easier fix than parsing sys.argv inside manage.py and inserting the configured port?
目标是运行 ./ manage.py runserver ,而不必每次都指定地址和端口,但需要参数从 config.ini 。
The goal is to run ./manage.py runserver without having to specify address and port every time but having it take the arguments from the config.ini.
推荐答案创建一个bash脚本,以下:
create a bash script with the following:
#!/bin/bash exec ./manage.py runserver 0.0.0.0:<your_port>将其作为runserver保存在与manage.py相同的目录中
save it as runserver in the same dir as manage.py
chmod +x runserver并运行它作为
./runserver更多推荐
django更改默认的runserver端口
发布评论