Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t让django storages设置defaultStorage_Django_Heroku_Amazon S3 - Fatal编程技术网

Can';t让django storages设置defaultStorage

Can';t让django storages设置defaultStorage,django,heroku,amazon-s3,Django,Heroku,Amazon S3,我正在使用Amazon AWS S3,并尝试将我的Django应用程序设置为部署在Heroku上,并使用Django存储包(也使用boto)设置静态和媒体文件 My settings.py包括以下内容: DEBUG = False STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirector

我正在使用Amazon AWS S3,并尝试将我的Django应用程序设置为部署在Heroku上,并使用
Django存储
包(也使用
boto
)设置静态和媒体文件

My settings.py包括以下内容:

DEBUG = False
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
   'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

if not DEBUG:
    DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
    AWS_STORAGE_BUCKET_NAME = os.environ['AWS_STORAGE_BUCKET_NAME']
    STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
    S3_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
    STATIC_URL = S3_URL
    ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

INSTALLED_APPS += (
    'storages',
)
但是,当我登录控制台查看是否设置了默认存储时,根据
django存储
,我没有得到应该得到的东西

下面是我的shell会话的一个示例:

>>> from django.core.files.storage import default_storage
>>> print default_storage.__class__
<class 'django.core.files.storage.DefaultStorage'>
>>从django.core.files.storage导入默认存储
>>>打印默认存储。\u类__
根据指南,我应该把这个拿回来:

>>> from django.core.files.storage import default_storage
>>> print default_storage.__class__
<class 'S3Storage.S3Storage'>
>>从django.core.files.storage导入默认存储
>>>打印默认存储。\u类__
我已尝试将我的settings.py导入交互式shell。不走运。但是,我的其他AWS设置存储良好,例如S3_URL,它正在检索env变量并插入amazon URL

有人能给我一个线索吗


TIA.

您安装了boto吗?如果boto安装不正确,如果django storages无法正确导入boto,它可能会将您设置回默认存储类。

是的,我已经通过pip安装了boto 2.9.8。