django change default runserver port
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?
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
.
Solution 1:
create a bash script with the following:
#!/bin/bash
exec ./manage.py runserver 0.0.0.0:<your_port>
save it as runserver in the same dir as manage.py
chmod +x runserver
and run it as
./runserver
Solution 2:
Actually the easiest way to change (only) port in development Django server is just like:
python manage.py runserver 7000
that should run development server on http://127.0.0.1:7000/