6👍
✅
Use the os
module to execute the command:
import os
from django.shortcuts import render
def command_view(request):
output = os.popen('ls -l').read()
return render(request, 'command.html', {'output': output})
And put the result of the command into the <pre>
tag:
<pre>{{ output }}</pre>
Source:stackexchange.com