python - Django custom static files not collected to s3 bucket -


i'm configuring django project use s3 buckets store static , media files, both local , production settings.

my project tree follows:

   src/       blog/           settings/                   __init__                   local.py                   production.py           s3utils.py           [..]       [..] 

my local.py:

access_key = "xx" secret_key = "yy"  aws_access_key_id = access_key aws_secret_access_key = secret_key aws_storage_bucket_name = 'zz'   staticfiles_storage = 'blog.s3utils.staticroots3botostorage' default_file_storage = 'blog.s3utils.mediaroots3botostorage' s3direct_region = 'us-west-2' s3_url = 'http://%s.s3.amazonaws.com/' % aws_storage_bucket_name media_url = 'http://%s.s3.amazonaws.com/media/' % aws_storage_bucket_name media_root = media_url static_url = s3_url + "/static/" admin_media_prefix = static_url + 'admin/'  import datetime  two_months = datetime.timedelta(days=61) date_two_months_later = datetime.date.today() + two_months expires = date_two_months_later.strftime("%a, %d %b %y 20:00:00 gmt")  aws_headers = {      'expires': expires,     'cache-control': 'max-age=%d' % (int(two_months.total_seconds()), ), } 

my s3utils.py:

from storages.backends.s3boto import s3botostorage  staticroots3botostorage = lambda: s3botostorage(location='static')  mediaroots3botostorage  = lambda: s3botostorage(location='media')  

when run:

python manage.py collectstatic 

only (django) admin static files copied s3 bucket.

i thought problem misconfigured permission of iam user, have permissions copy 'admin/' files s3 bucket.

thank can provide.

add staticfiles_dirs settings.

staticfiles_dirs = [     "/path/to/your/static", ] 

https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-staticfiles_dirs


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -