Skip to content
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

Open
pziewiec opened this issue Nov 25, 2023 · 1 comment
Open

django 4.2 - storage options (problem with s3 and template tag) #748

pziewiec opened this issue Nov 25, 2023 · 1 comment

Comments

@pziewiec
Copy link

@lru_cache
def get_or_create_storage(storage):
    return get_module_class(storage)()

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

@emdede
Copy link

emdede commented Sep 26, 2024

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 sorl-thumbnail is used in conjunction with filer because filer at the moment has a similar problem. To fix this particular issue there is at least no need to manually patch code but you do have to explicitly set the FILER_STORAGES engine options:

# 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,
            },
        },
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants