Configuring Django / Wagtail Media to Use S3
I am using the following guide:
https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/
The section that instructs you on how to "configure Django media to use S3". I am using this for Wagtail.
It is not clear where to set the "custom_storages.py" settings. All over the place I put it, doesn't seem to work. At this point I am back in Withenoise.
Thank!
You need to set the STATICFILES_STORAGE parameter
STATICFILES_STORAGE = 'path/to/custom_storages.StaticStorage'
If you are using wagtail (which I assume you are doing, since you are putting this question along with it), you can put it in the default home / directory and reference it like this: 'home / custom_storages.StaticStorage
The content of custom_storages.py is specified in the guide you follow:
# custom_storages.py
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class StaticStorage(S3BotoStorage):
location = settings.STATICFILES_LOCATION
Edit: I have a GitHub repository (also a wagtail project) where I use this code, but only for my media. You can check it out here .
You can put custom_storages.py anywhere in your Python path. Django will try to find the class using the value of the STATICFILES_STORAGE parameter, which in the example is "custom_storages.StaticStorage". So Django will essentially "import custom_storages" and use "custom_storages.StaticStorage" as the storage class. Just make sure you can "import custom_storages" and it should work.