How to set-up a Django project with django-storages and Amazon S3, but with different folders for static files and media files?

I think the following should work, and be simpler than Mandx’s method, although it’s very similar:

Create a s3utils.py file:

from storages.backends.s3boto import S3BotoStorage

StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static')
MediaRootS3BotoStorage  = lambda: S3BotoStorage(location='media')

Then in your settings.py:

DEFAULT_FILE_STORAGE = 'myproject.s3utils.MediaRootS3BotoStorage'
STATICFILES_STORAGE = 'myproject.s3utils.StaticRootS3BotoStorage'

A different but related example (that I’ve actually tested) can be seen in the two example_ files here.

Leave a Comment