2👍
Solved this issue. The root cause of the issue due to python cannot open file with relative path. So we can solve this issue in two steps.
- Open file from absolute path as below(use absolute path)
f = open(settings.MEDIA_ROOT + '/text_file/'+ text_file + '.txt','w') f.close()
- then update/save file(use relative path)
queryset.filter(pk=voice.pk).update(textFile='text_file/' + text_file + '.txt')
Hope can help someone who hit similar question.
Source:stackexchange.com