'django project does not write to file and there is no error, the file does not appear
I'm trying to write to a file and django doesn't do it. There is no error of any kind but the file does not appear. Using the process monitor I don't see any attempt to write. In a python file the same code works fine.
Test performed:
@method_decorator(login_required, name='dispatch')
class TestWrite(TemplateView):
template_name = 'test.html'
with open(r'd:\djangotest.txt', "w") as fo:
fo.write('test')
fo.close()
I did the test with Popen and it doesn't work either.
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout, stderr = p.communicate()
returncode = p.returncode
In the case of Popen I used pg_dump.exe and in stderr I got the result of the program running correctly but no file anywhere.
It doesn't matter which path you select to write, inside the project, outside of it, ect. the file does not appear.
I don't know if it's important, but I did the tests in pycharm.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|