4

Using Django 1.5rc (tried 1.4 too) I am trying to make the CachedStaticFilesStorage work with Boto.

When I use CachedStaticFilesStorage without Boto it works just fine:

DEFAULT_FILE_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'

STATICFILES_S3_OPTIONS = {
    "bucket": "bucket-name"
}

python manage.py collectstatic

Copying '/user/project/static/css/min/styles.min.css'
Copying '/user/project/static/js/min/scripts.min.js'
Post-processed 'styles.min.css' as 'styles.min.694c8cd7e18b.css
Post-processed 'scripts.min.js' as 'scripts.min.1111e876b4f7.js

However, when I change the storage backend this is what happens:

DEFAULT_FILE_STORAGE = "storages.backends.s3boto.S3BotoStorage"
STATICFILES_STORAGE = "project.storage.CachedStaticS3BotoStorage"

python manage.py collectstatic

Copying '/user/project/static/css/min/styles.min.css'
Copying '/user/project/static/js/min/scripts.min.js'


File "/user/.virtualenvs/project/lib/python2.7/site-packages/boto/s3/bucket.py", line 461, in new_key
    raise ValueError('Empty key names are not allowed')
ValueError: Empty key names are not allowed
ValueError: Empty key names are not allowed

Here is my storage.py

from django.conf import settings
from django.contrib.staticfiles.storage import CachedFilesMixin
from storages.backends.s3boto import S3BotoStorage


class CachedStaticS3BotoStorage(CachedFilesMixin, S3BotoStorage):
    def __init__(self, *args, **kwargs):
        kwargs.update(getattr(settings, "STATICFILES_S3_OPTIONS", {}))
        super(CachedStaticS3BotoStorage, self).__init__(*args, **kwargs)
4

0 回答 0