this question relates to customization using Heroku, django-storageages (w / boto for s3) and CloudFront for static content.
I have been trying for the past few hours to successfully upload my static files to my Heroku application. I successfully got Cloudfront connected to my s3 bucket and it seems that the bucket is configured correctly, but for some reason my value for AWS_STORAGE_BUCKET_NAME does not seem to be logged correctly.
If anyone has any tips or ideas on how to debug this, I would be very obliged. I am at my end. Thank you for reading.
settings.py (important stuff):
try: from settings_local import * except: import s3utils DEBUG = False
s3utils.py
from storages.backends.s3boto import S3BotoStorage from django.utils.functional import SimpleLazyObject import os AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID'] AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY'] AWS_STORAGE_BUCKET_NAME = 'static.[website].org' StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static') MediaRootS3BotoStorage = lambda: S3BotoStorage(location='media')
This is the trace that I get when I try to collect static data either through the "launch of the hero" or in the Procfile file:
Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.__dict__) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle return self.handle_noargs(**options) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs collected = self.collect() File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 113, in collect handler(path, prefixed_path, storage) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 287, in copy_file if not self.delete_file(path, prefixed_path, source_storage): File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 215, in delete_file if self.storage.exists(prefixed_path): File "/app/.heroku/python/lib/python2.7/site-packages/storages/backends/s3boto.py", line 284, in exists return k.exists() File "/app/.heroku/python/lib/python2.7/site-packages/boto/s3/key.py", line 399, in exists return bool(self.bucket.lookup(self.name)) File "/app/.heroku/python/lib/python2.7/site-packages/boto/s3/bucket.py", line 148, in lookup return self.get_key(key_name, headers=headers) File "/app/.heroku/python/lib/python2.7/site-packages/boto/s3/bucket.py", line 181, in get_key query_args=query_args) File "/app/.heroku/python/lib/python2.7/site-packages/boto/s3/connection.py", line 458, in make_request auth_path = self.calling_format.build_auth_path(bucket, key) File "/app/.heroku/python/lib/python2.7/site-packages/boto/s3/connection.py", line 92, in build_auth_path path = '/' + bucket TypeError: cannot concatenate 'str' and 'NoneType' objects
Please note that I skipped domain names, etc., I actually do not have the code [domain] or [website].