Subprocess Popen to call a tasks file python which cannot able to load models in Django
I have Django app ..we have several tasks file(stored into tasks folder). And we want to call those tasks file from views.py
Now when we call
p = Popen("python","./tasks/task1.py", "jobid", stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
output_filename, err = p.communicate(b"input data that is passed to subprocess' stdin")
now in task1.py
from app.models import Job #its throwing error
It cannot import Models into task1.py where I have sent job id
from app.models import Job\r\nModuleNotFoundError: No module named \'app\'\r\n
Folder structure
project
|-app
|-models.py
|-views.py
|-tasks
|- task1.py