Python/Django newbie here!
In my new project, I am able to load the django template pages and the admin section, as well as update and delete things from the admin... I've been able to collectstatic without a problem and I can also run all commands with manage.py from bash, all from inside virtualenv.
Where I am stuck is trying to run a "python manage.py check" from the app's views.py via subprocess, for example:
some_app/views.py
from django.shortcuts import render
from django.http import HttpResponse
import subprocess
import shlex
def home(request):
cmd = 'python manage.py check'
subprocess.Popen(shlex.split(cmd))
return HttpResponse("<html><body>Hello World</body></html>")
The HTML "Hello World" loads fine, the subprocess command results in Apache error:
"python: can't open file 'manage.py': [Errno 2] No such file or directory".
"python: can't open file '../myweb/manage.py': [Errno 2] No such file or directory".
I am not sure I know why this is, here's the file structure I have:
- /var/www/project (venv)
- bin/
- include/
- lib/
- share/
- myweb/
- db.sqlite3
- manage.py
- myweb/
- some_app/
- views.py
- ect...
- tatic/
- templates/
If enyone has any tips I would appreciate it!
setup info:
- Ubuntu server 18.04
- Apache 2.4.29
- virtualenv w/python 3.6.7
- Django2.2.1