I've created a chat for this question: here
I have a view that attempts to execute f = open('textfile.txt', 'w')
but on my live server this brings up the error [Errno 13] Permission denied: 'textfile.txt'
.
My file structure is as follows:
- root
|
- project
|
- app
|
- media
where the view lives in app
.
I have tried having textfile.txt live in root, project, app and media all of which have 777 file permissions (owner, group and public can read, write and execute)[*1].
If I change the command to a read permission ie f = open('textfile.txt', 'r')
I get the same error.
My media root is set to os.path.join(os.path.dirname(__file__), 'media').replace('\\','/')
and this is all running on an apache server through webfaction.
So I have two questions. Where is django/python trying to open this file from? and what do I need to change to get permission for the view to open and write to the file.
[*1] I know this is not a good idea, I just have this set for current debugging purposes.
EDIT:
I don't know if this is relevant but now when I change it to f = open(os.path.join(settings.MEDIA_URL, 'textfile.txt'), 'r')
rather than f = open(os.path.join(settings.MEDIA_URL, 'textfile.txt'), 'w')
I get the error [Errno 2] No such file or directory
.
I don't know if this has meaning or not...