You can start the Django shell from the command line:
python manage.py shell
Then import execute_from_command_line :
from django.core.management import execute_from_command_line
And finally, you can execute the necessary commands:
execute_from_command_line(["manage.py", "syncdb"])
It should solve your problem.
Alternatively, you can also take a look at the documentation of the subprocess module . You can execute the process and then check its output:
import subprocess output = subprocess.check_output(["python", "manage.py", "syncdb"]) for line in output.split('\n'):
Valdir Stumm Junior
source share