Monday, November 27, 2017

FileField - not stored to disk when using mod_wsgi?

I ave django file upload application. I have a model looking like this:

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:

  1. The HTTP POST returns status 200.
  2. A subsequent GET will return the files in question.

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.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6ed264e4-144f-4943-aa28-a155da21366c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment