[Solved]-Wrong url with Django Sorl thumbnail with Amazon s3

31👍

I’ll bet that you’re using something like this:

MediaS3BotoStorage = lambda: S3BotoStorage(location='media')

However this causes problems in sorl-thumbnail because it serializes the storage class into cache using the class name. Later when it deserializes, it instantiates as S3BotoStorage() without the location parameter. That’s why it works the first time for you but then fails later.

You can fix it by using a full-fledged class instead of a factory:

class MediaS3BotoStorage(S3BotoStorage):
    location = 'media'

Hope that helps!

Leave a comment