brandizzi
brandizzi

Reputation: 27050

How to start Django up programmatically

Suppose I have a Django app (for example, myapp) and a Python script (let us say, myscript.py) both in the same directory. How could I start (and stop) the Django app from the script? Is there an object or function for this? Or should I use the subprocess trick?

Upvotes: 3

Views: 1159

Answers (1)

David Wolever
David Wolever

Reputation: 154504

Use django.core.management.call_command.

For example:

from django.core import management
management.call_command('runserver')

Upvotes: 10

Related Questions