我正在尝试通过管理区域将图像上传到gcloud服务器,但显示 错误
No module named 'config'
我正在使用gcloud代理来使用gcloud数据库
这是错误记录-
Traceback (most recent call last):
File "F:\duit\duit_backend_env\lib\site-
packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "F:\duit\duit_backend_env\lib\site-
packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "F:\duit\duit_backend_env\lib\site-
packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args,
**callback_kwargs)
File "F:\duit\duit_backend_env\lib\site-
packages\django\contrib\admin\options.py", line 606, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "F:\duit\duit_backend_env\lib\site-
packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
...
File "F:\duit\duit_backend_env\lib\importlib\__init__.py", line 126, i
n import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _
find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _
call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in
_find_and_load_unlocked
ModuleNotFoundError: No module named 'config'
编辑2-
DEFAULT_FILE_STORAGE = 'config.storage_backends.GoogleCloudMediaStorage'
#STATICFILES_STORAGE = 'config.storage_backends.GoogleCloudStaticStorage'
GS_PROJECT_ID = 'myid'
GS_MEDIA_BUCKET_NAME = 'mybucket'
#GS_STATIC_BUCKET_NAME = 'mybucket'
#STATIC_URL = 'https://storage.googleapis.com/{}/'.format(GS_STATIC_BUCKET_NAME)
MEDIA_URL = 'https://storage.googleapis.com/{}/'.format(GS_MEDIA_BUCKET_NAME)
答案 0 :(得分:1)
您的设置DEFAULT_FILE_STORAGE = 'config.storage_backends.GoogleCloudMediaStorage'
错误。我不知道你从哪里得到的。
如果您在docs of django-storages中阅读了有关设置Google云存储的说明,则会看到正确的设置是:
DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage'