Reputation: 27050
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
Reputation: 154504
Use django.core.management.call_command
.
For example:
from django.core import management
management.call_command('runserver')
Upvotes: 10