I want to run my script (makes changes to my database and creates users on another website using an API) whenever a user presses the button on my website. So far i have tried these solutions but they are not working for me.
How can i trigger a Python script in background from HTML tag button, in Django?
Run python script in Django website when clicking on button submit
The view
def external(request):
out = run([sys.executable, 'C:\\Users\\hafiz\\PycharmProjects\\DotsPrototype\\proto\\moodle.py'], shell=False, stdout=PIPE)
print(out.stdout)
return render(request, 'proto/index.html', {'data1': out.stdout})
The error
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'DotsPrototype'
b''
.
.
.
/external/vendor/jquery/jquery.min.js