Adds easy python 3 and 2.7 support to Django for management of static assets. This is a wrapper around the excellent Apache Libcloud library.
The full documentation is at https://dj-libcloud.readthedocs.org.
Libcloud verifies server SSL certificates before it lets you do anything. It will search your system for the CA certificate, and if it doesn't find it then it will blow up. See https://libcloud.readthedocs.org/en/latest/other/ssl-certificate-validation.html
Installing CA certificate bundle on Mac OS X:
# Assuming you are using homebrew for Mac OS X dependency management. $ brew install curl-ca-bundle
Install dj-libcloud:
$ pip install dj-libcloud
Then use it in a project, e.g. for both your media and static files:
# settings.py LIBCLOUD_PROVIDERS = { 'default': { 'type': 'libcloud.storage.types.Provider.S3', 'user': os.environ.get('AWS_ACCESS_KEY'), 'key': os.environ.get('AWS_SECRET_KEY'), 'bucket': 'uploaded-media', 'base_url': 'https://s3.amazonaws.com/uploaded-media/', }, 'static': { 'type': 'libcloud.storage.types.Provider.S3', 'user': os.environ.get('AWS_ACCESS_KEY'), 'key': os.environ.get('AWS_SECRET_KEY'), 'bucket': 'static-assets', 'base_url': 'https://s3.amazonaws.com/static-assets/', }, } DEFAULT_FILE_STORAGE = 'djlibcloud.providers.default' MEDIA_URL = LIBCLOUD_PROVIDERS['default']['base_url'] STATICFILES_STORAGE = 'djlibcloud.providers.static' STATIC_URL = LIBCLOUD_PROVIDERS['static']['base_url']
If you want to use other libcloud providers (Rackspace, Openstack, other AWS centers, et al), please visit:
- Works for uploading media assets using Python 3.3 and Django 1.6.
- In theory supports all the backends that libcloud supports.
Because you just had to ask.
Those are great libraries, but are not what you want when handling user uploaded media.
libcloud is awesome and has a dedicated team devoted to it. We can have it do most of the heavy lifting. On the other hand, converting django-storages to work with Python 3 looked like too much work. Sometimes you just have to start anew, right?
dj-libcloud is a wrapper around libcloud, meaning it supports all the providers of that library. Check out the full list of supported providers!
Please read http://dj-libcloud.readthedocs.org/en/latest/contributing.html
Working on it. Currently the PipelineCachedCloudStorage class breaks the second time you run it. See pydanny#7
Many thanks to Jannis Leidel (@jezdez) for giving me the code to get this started. He's a Django core developer, the master of Django static asset managment, and overall a great great guy.