Django specify default address and default port when run server

Viewed 575

Is there a way i can specify the IP:Port in DJANGO_SETTINGS_MODULE (setting.py), instead of using

python manage.py runserver <ip>:<port>?

like we specify ALLOWED_HOST, INTERNAL_IPS etc

1 Answers

You can add default address and default port in your settings.py:

from django.core.management.commands.runserver import Command as runserver

ALLOWED_HOSTS = ['*']
runserver.default_port = '8000'        # <-- Your port
runserver.default_addr = '127.0.0.1'   # <-- Your address

Then just need run python manage.py runserver

Related