pythondjangodjango-manage.pymanage.py

How to change the Django 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

  • 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