Django runserver from Python script <p>The normal way to start the Django server is to run the following command from a terminal or a bash script:</p> <pre><code>python manage.py runserver [Ip.addr]:[port] </code></pre> <p>e.g. </p> <pre><code>python manage.py runserver 0.0.0.0:8000 </code></pre> <p>How can I start a Django server from a Python script?</p> <p>One option is the following </p> <pre><code>import os if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings") from django.core.management import execute_from_command_line args = ['name', 'runserver', '0.0.0.0:8000'] execute_from_command_line(args) </code></pre> <p>Is there a better way?</p>