class BaseFile(Model):
input_name = CharField( max_length = 132 )
content = FileField( upload_to = "%Y/%m/%d" )
upload_time = DateTimeField( auto_now_add=True )
owner_group = CharField( max_length = 32 , default = None )
In the settings.py
file I have set:
MEDIA_ROOT = "/tmp/storage"
When I use this with the development server things seem to work, I can upload files and if I go to the /tmp/storage
directory I can see the %Y/%m/%d
directories created and populated with my files.
When I try this using Apache and mod_wsgi things also seem to work:
But - when I go the /tmp/storage
directory there are no directories/files to be found and if I stop and start Apache the GET will fail with:
IOError:
No such file: /tmp/storage/2017/11/27/FILEX_Z1OZMf8
So - it seems to me that Django keeps the files in memory when using mod_wsgi
? I am using 100% default Django settings when it comes to storage backend. I see no errors in the Apache log.
I suspect this might be due to permissions, because on linux, /tmp is owned by root and the apache service runs as user apache.
Can you confirm that you're using mod_wsgi_py3 for python3 and not regular mod_wsgi, which is for python2 only.
What's your view that's responsible for handling that model instanciation?
/tmp is for temporary files, and its very possible Apache is cleaning up those files created through its process when you terminate the server.
I would create a different folder path and use that.