Django storage s3 media url is https:// instead of http://

拜拜、爱过 提交于 2019-12-03 11:59:19

I would try adding this property to your settings:

AWS_S3_SECURE_URLS = False

It doesn't look like it's documented after a brief glance at the django-storages docs, but this blog talks about it a bit more. http://www.eliotk.net/05/30/force-http-with-django-storages-and-s3boto/

You could probably solve this with a single AWS_S3_SECURE_URLS = False. However these settings are in flux as of the current version 1.1.6 so here's a bit more detail on related settings:

AWS_S3_SECURE_URLS = False
AWS_S3_URL_PROTOCOL = 'http'
AWS_STORAGE_BUCKET_NAME = 'mybucket'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME

AWS_S3_URL_PROTOCOL is the new way and if set to an empty string allows protocol relative URLs. For backwards compatibility you still need AWS_S3_SECURE_URLS. And at the moment AWS_S3_CUSTOM_DOMAIN is necessary if you are using AWS_S3_URL_PROTOCOL. Here's some developer discussion on implementing protocol relative URLs with the S3Boto backend.

It's also worth noting Django-storages provides an S3 backend as well as a different S3Boto backend. Your question doesn't make the one you are using clear though your code does.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!