[Django]-Is it possible to run ubuntu terminal commands using DJango

0👍

have django make a call to a subprocess like the one below. each string in the command should be a string in a list.

import subprocess
subprocess.call(["ls", "-l"])

0👍

You don’t need to search for Django implemented libraries, Django is written in python and python is providing libraries for it.

An alternative solution

import subprocess
subprocess.Popen(['python', 'manage.py', 'runserver'])

you can excecute shell commands using subprocess.Popen also.
The difference between subprocess Popen and call and how to use them is described here What's the difference between subprocess Popen and call (how can I use them)?

Leave a comment