【发布时间】:2020-01-05 16:11:33
【问题描述】:
我已经执行了以下步骤,但是底部的错误一直显示:
install pip install django-google-cloud-storage
add in setting.py file
DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage'
GS_BUCKET_NAME = 'is_image_bucket'
发现导入错误 - 没有名为 storages 的模块
我也试过这个教程 https://libraries.io/pypi/django-google-cloud-storage
配置
在您的 django settings.py 文件中,您需要添加以下设置
GOOGLE_CLOUD_STORAGE_BUCKET = '/your_bucket_name' # the name of the bucket you have created from the google cloud storage console
GOOGLE_CLOUD_STORAGE_URL = 'http://storage.googleapis.com/bucket' #whatever the ulr for accessing your cloud storgage bucket
GOOGLE_CLOUD_STORAGE_DEFAULT_CACHE_CONTROL = 'public, max-age: 7200' # default cache control headers for your files
And finally declare the file storage backend you will use on your settings.py file
DEFAULT_FILE_STORAGE = 'django_google_cloud_storage.GoogleCloudStorage'
ModuleNotFoundError 在 /api/photo_docs/ 没有名为“django_google_cloud_storage”的模块
【问题讨论】:
-
您能否更清楚地格式化您的问题,并添加您尝试过的内容以及有效/无效的内容,以及任何代码。
-
您能分享一下您的 settings.py 吗?为了更好的了解,我想你是在关注this tutorial吧?
标签: django python-3.x google-app-engine django-rest-framework