-
-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django 4.2 - storage options (problem with s3 and template tag) #748
Comments
For anyone that finds themselves here looking for a solution. This is what I did as a workaround in my project: # my_app/utils.py
def alias_default_storage(*args):
from django.core.files.storage import storages
return storages["default"] # or another key
# settings.py
THUMBNAIL_STORAGE = "my_app.utils.alias_default_storage"
from sorl.thumbnail import images
from my_app.utils import alias_default_storage
images.get_or_create_storage = alias_default_storage There is also an additional problem when # settings.py
FILER_STORAGES = {
"public": {
"main": {
"ENGINE": "storages.backends.s3.S3Storage",
# Mirror the OPTIONS kwargs provided to your django storage
"OPTIONS": {
"bucket_name": media_bucket_name,
"querystring_auth": False,
},
},
}
} |
Hi, I wanted to chime in here in 2025: I'm ran into the same issue with google cloud storage. sorl-thumbnail 12.11.0 with Django 5.0.4, django-storages 1.14.3, google-cloud-storage 2.17.0. The ValueError: Cannot determine path without bucket name. The workaround from @emdede above works. My storage config: STORAGES = {
"default": {
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
"OPTIONS": {
"project_id": "my-project",
"file_overwrite": False,
"blob_chunk_size": 5 * 1024 * 256,
"credentials": ... get secret ...,
"bucket_name": "my-bucket",
},
}
} Here's the full trace: ERROR Thumbnail tag failed
Traceback (most recent call last):
File ".../.venv/lib/python3.11/site-packages/sorl/thumbnail/templatetags/thumbnail.py", line 55, in render
return self._render(context)
^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/sorl/thumbnail/templatetags/thumbnail.py", line 135, in _render
thumbnail = get_thumbnail(file_, geometry, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/sorl/thumbnail/shortcuts.py", line 8, in get_thumbnail
return default.backend.get_thumbnail(file_, geometry_string, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/sorl/thumbnail/base.py", line 102, in get_thumbnail
if settings.THUMBNAIL_FORCE_OVERWRITE or not thumbnail.exists():
^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/sorl/thumbnail/images.py", line 127, in exists
return self.storage.exists(self.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/storages/backends/gcloud.py", line 247, in exists
return bool(self.bucket.get_blob(name))
^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/google/cloud/storage/bucket.py", line 1276, in get_blob
blob.reload(
File ".../.venv/lib/python3.11/site-packages/google/cloud/storage/_helpers.py", line 301, in reload
self.path,
^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/google/cloud/storage/blob.py", line 334, in path
return self.path_helper(self.bucket.path, self.name)
^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/google/cloud/storage/bucket.py", line 1173, in path
raise ValueError("Cannot determine path without bucket name.")
ValueError: Cannot determine path without bucket name. |
sorl/thumbnail/images.py:23 - storage options parameter is missing
check this way:
https://github.com/django/django/blob/b0ec87b8578147be4357c90eabcd2b916c780810/django/core/files/storage/handler.py#L38C38-L38C38
The text was updated successfully, but these errors were encountered: