Can't collectstatic to s3 via Heroku using boto - s3 bucket returns a NoneType

前端 未结 1 1513
情书的邮戳
情书的邮戳 2020-12-10 08:42

this question pertains to a setup using Heroku, django-storages (w/ boto for s3), and CloudFront to serve static content.

I\'ve been trying for the past several hour

相关标签:
1条回答
  • 2020-12-10 09:31

    You are not saying from s3utils import *, so AWS_STORAGE_BUCKET_NAME is never imported into the settings module.

    S3BotoStorage will pull AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from environment variables, but AWS_STORAGE_BUCKET_NAME must be set in settings.py. This seems like a bizarre inconsistency, but I think it is because AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are actually boto parameters and AWS_STORAGE_BUCKET_NAME is not (boto will pull credentials from env vars).*

    The other references to s3utils are explicit:

    DEFAULT_FILE_STORAGE = 's3utils.MediaRootS3BotoStorage'
    STATICFILES_STORAGE = 's3utils.StaticRootS3BotoStorage'
    

    So, the only setting that isn't taken care of is AWS_STORAGE_BUCKET_NAME, and that causes your error.

    *I'd like to see django-storages accept other settings from env vars (12-Factor App, anyone?) and am considering opening an issue/submitting a pull request to that effect.

    0 讨论(0)
提交回复
热议问题