django更改默认的runserver端口

编程入门 行业动态 更新时间:2024-10-25 23:27:27
本文介绍了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端口

本文发布于:2023-08-07 03:41:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1316770.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:端口   django   runserver

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!