How to start Django programmatically

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

+2
source share
1 answer

Use django.core.management.call_command .

For instance:

 from django.core import management management.call_command('runserver') 
+6
source

Source: https://habr.com/ru/post/1383118/


All Articles