[Django]-Django collectstatic result in S3ResponseError: 301 Moved Permanently

5๐Ÿ‘

โœ…

I figured out that the problem is because an update to the Django module django-storages that I used. In the update they have added a default value to S3BotoStorage.host by assigning it in the following way:

host = setting('AWS_S3_HOST', S3Connection.DefaultHost)

What happens is that the host is automatically set to s3.amazonaws.com and because it already have a host set when it creates the connection with boto (AWS official python-package), it never uses the DefaultHost = "s3-eu-west-1.amazonaws.com" that I added in my EuropeConnection-class.

The way to solve this problem is to set django-storages settings value AWS_S3_HOST (New) in your settings.py.

AWS_S3_HOST = "s3-eu-west-1.amazonaws.com"
๐Ÿ‘คMarcus Lind

Leave a comment