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?
Use django.core.management.call_command.
For example:
from django.core import management
management.call_command('runserver')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With