Image thumbnail goes bad after one page view

43 views
Skip to first unread message

King Olami

unread,
Apr 27, 2018, 8:44:34 AM4/27/18
to django-oscar


For some reason yet unknown to me, a product's thumbnails disappear from view after just a single load of a page (both in Dashboard and Product Detail view) because the template seems to be truncating the URLs. This problem doesn't happen to statics at all.

To replicate:

1. Upload an image for a product using the dashboard. The image gets stored in the correct S3 bucket, media path,is accessible by all, and so on. (confirmed with django admin, AWS Console and sorl debug logging)

2. System returns the correct working URL https://s3.amazonaws.com/mybucket/media/cache/XXX/YYY/ZZZ.jpg that works on first page view request.

3. Reload the page. System returns broken URL https://s3.amazonaws.com/mybucket/cache/XXX/YYY/ZZZ.jpg (missing 'media' path)

4. Running python manage.py thumbnail cleanup, python manage.py thumbnail clear, restart gunicorn takes up back to step 2


Am I missing something? Should I be looking at sorl.thumbnail or oscar templates?




Some relevant settings and data:

Snippet from pip requirements
sorl-thumbnail==12.3
boto==2.38.0
django-storages==1.1.8
awscli==1.7.39

Snippet from settings.py

THUMBNAIL_DEBUG = True
THUMBNAIL_PRESERVE_FORMAT=True
OSCAR_IMAGE_FOLDER = 'images/products/'

AWS_STORAGE_BUCKET_NAME = 'mybucket'     
AWS_ACCESS_KEY_ID = 'mykey'
AWS_SECRET_ACCESS_KEY = 'mysecret'
AWS_S3_CUSTOM_DOMAIN = 's3.amazonaws.com/%s' % AWS_STORAGE_BUCKET_NAME

STATICFILES_LOCATION = 'static'
MEDIAFILES_LOCATION = 'media'
DEFAULT_FILE_STORAGE = 'utils.MediaRootS3BotoStorage'
STATICFILES_STORAGE = 'utils.StaticRootS3BotoStorage'

STATIC_ROOT = location('static')
MEDIA_ROOT = location('media')
STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION)
MEDIA_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION)

Entire utils.py
from storages.backends.s3boto import S3BotoStorage

StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static')
MediaRootS3BotoStorage  = lambda: S3BotoStorage(location='media')

Entire thumbnail_kvstore db
                             key                              |                                                                 value
--------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------
 sorl-thumbnail||image||e14a50914a152da773157a34d30d4ab4      | {"storage": "storages.backends.s3boto.S3BotoStorage", "name": "images/products/ZZZ.jpg", "size": [2000, 3000]}
 sorl-thumbnail||image||5cab03b2ed5b48fccd2309abdddd8d7e      | {"storage": "storages.backends.s3boto.S3BotoStorage", "name": "cache/ee/25/ee25c9c57c544b0eadaa892c6bd1ce84.jpg", "size": [267, 400]}
 sorl-thumbnail||thumbnails||e14a50914a152da773157a34d30d4ab4 | ["5cab03b2ed5b48fccd2309abdddd8d7e"]
 sorl-thumbnail||image||8a767e549b0b784968c1e5aca445532a      | {"storage": "storages.backends.s3boto.S3BotoStorage", "name": "cache/60/84/608471a1fac28fb8b5c885e95d3d8797.jpg", "size": [103, 155]}


This question was asked before but has not received an answer 

King Olami

unread,
Apr 27, 2018, 9:48:19 AM4/27/18
to django-oscar

dk ni

unread,
Aug 25, 2018, 4:14:32 AM8/25/18
to django-oscar
Hi 
I got the same issue, have u fix that problem?

BTW the solution link is broken
Reply all
Reply to author
Forward
0 new messages