[Solved]-Django-Storages S3 with minio as backend

13👍

Here is what I did to get it to work

# settings.py

STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

AWS_STORAGE_BUCKET_NAME = 'static'

AWS_ACCESS_KEY_ID = minio_access_key
AWS_SECRET_ACCESS_KEY = minio_secret_key
AWS_S3_ENDPOINT_URL = minio_address (eg. http://localhost:9000)

Versions:

  • boto3==1.10.45
  • Django==3.0.1
  • django-storages==1.8
  • Minio==2019-12-26T01:55:09Z (Docker image built from the source code to run on RPi4)

Note: versions were latest when installed using pip install <package>

I didn’t attempt to use django-minio-storage since it does not support Django3.

If you have upgraded your package versions, try what I did. If not try setting S3_HOST = '127.0.0.1:9000' .

AWS_S3_ENDPOINT_URL from django-storage docs

AWS_S3_ENDPOINT_URL (optional: default is None, boto3 only)
Custom S3 URL to use when connecting to S3, including scheme. Overrides AWS_S3_REGION_NAME and AWS_S3_USE_SSL . To avoid AuthorizationQueryParametersError error, AWS_S3_REGION_NAME should also be set.

Troubleshooting
Disconnect from the internet and run manage.py collectstatic to see the address to which boto fails to connect.

👤Yuri L

Leave a comment