我创建了一个自定义存储后端,该文件被调用storages.py
并放置在一个名为core
:
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class S3StaticBucket(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['bucket_name'] = getattr(settings, 'static.mysite.com')
super(S3BotoStorage, self).__init__(*args, **kwargs)
在settings.py
中,我有以下内容:
STATICFILES_STORAGE = 'core.storages.S3StaticBucket'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
当我尝试这样做python manage.py collectstatic
时,会显示以下错误:
django.core.exceptions.ImproperlyConfigured: Error importing storage module core.storages: "No module named backends.s3boto"
当我运行python manage.py shell
并尝试导入相同的内容时:
>>>
>>> from django.conf import settings
>>> from storages.backends.s3boto import S3BotoStorage
>>>
知道我做错了什么吗?