[Django]-Django collectstatic giving no errors. But staticfiles not loading on website with both debug true and false. Files on S3

3👍

I can see STATIC_URL and MEDIA_URL not setup correctly.

change

STATIC_URL = 'https://%s.static/' % AWS_S3_DOMAIN
MEDIA_URL = 'https://%s.media/' % AWS_S3_DOMAIN

To

STATIC_URL = 'https://%s/static/' % AWS_S3_DOMAIN
MEDIA_URL = 'https://%s/media/' % AWS_S3_DOMAIN

It should work.

The following link has a very good explanation.
https://simpleisbetterthancomplex.com/tutorial/2017/08/01/how-to-setup-amazon-s3-in-a-django-project.html

0👍

I had the same issue but with me it was a ACL issue. I could only get collectstatic to run if I set AWS_DEFAULT_ACL=None but then all the files would be set to private by default and couldn’t access them from the app.

To fix I had to change the S3 bucket Object Ownership to Bucket owner preferred so that it accepted the public-read ACL.

Leave a comment