1

I'm trying to serve the media and static files of my django app with a static service on dotcloud (http://stackoverflow.com/questions/13681183/serve-static-files-with-nginx-and-custom-service-dotcloud).

I created a static service where I put my static files. In my django settings, I have:

    STATIC_ROOT = STATIC_DIR
    STATIC_URL = 'http://mystaticapp.dotcloud.com/'

It works perfectly.

Concerning my media files, I put a folder media in my static service, and I have:

    MEDIA_ROOT = 'http://mystaticapp.dotcloud.com/media/'
    MEDIA_URL = 'http://mystaticapp.dotcloud.com/media/'

MEDIA_URL works find: my django app get the media from the static service.

But the problem happens with MEDIA_ROOT. It looks like the app is not uploading the files to my static app. When I upload profile picture for my users, it does not upload it to mystaticapp/media/profilepic, as it should.

Any idea on how I could solve that problem? Thank you.

Marcolac
  • 901
  • 4
  • 14
  • 27

1 Answers1

2

The important thing to remember is that the static service and your django service on dotCloud are separate services, that have no common file system. So if you upload a file to your django service, it won't be available to your static service.

For this use case I would recommend uploading your files to S3, and serving those files from there.

I would recommend Django-storages for this. Here is some documentation: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html

Ken Cochrane
  • 75,357
  • 9
  • 52
  • 60