Search code examples
djangoamazon-s3django-storagedjango-oscar

Django-Oscar with AWS S3 save images correctly


I'm using django-oscar with S3 storage from the storages S3BotoStorage library. My static files are stored in my s3 bucket at:

STATIC_URL = "https://s3.amazonaws.com/<my_bucket_name>/static/"

These are successfully collected when I run python manage.py collectstatic, so I know I have my S3 permissions set correctly.

My MEDIA_URL is set to:

MEDIA_URL = "https://s3.amazonaws.com/<my_bucket_name>/media/"

When I run python manage.py oscar_import_catalogue_images, the images are saved to my S3 bucket, howerver, they are placed in:

<bucket_name>/images/products/2016/02/<image_file>

Although they are saved here, they are not correctly rendered on my site.

The images are rendered as an empty <div>, with large whitespace surrounded by quotes.

How can I get the images to be correctly rendered, and have sorl properly generate thumbnails from the S3 images?

Based on my preliminary research, I would have to edit the utils.py Importer class somehow to change the directory. But I'm not sure that would help with how they are rendered. Has anyone encountered this issue before?


Solution

  • The issue was I was using a version of Python Image Library (PIL), that did not support my image format. After I pip uninstall'ed PIL, I added the necessary support libraries, and then reinstalled PIL. This solved the issue.