femiir
femiir

Reputation: 310

Django collectstatic is not pushing to AWS S3

I have searched and reconfigured my project so many times. I have created new AWS accounts but am still having the same issue.

python manage.py collectstatic keeps reverting to an old folder I used while using whitenoise. i have commented out the whitenoise middleware and the whitenoise from apps i installed boto3, django-storages..

each time i run collectstatic it creates a new directory staticfiles and displays

286 static files copied to '/home/user/Documents/django-project/staticfiles', 841 post-processed.

I tried the command python manage.py collectstatic --noinput --clear but get the same output.

my AWS S3 bucket config for Django

# AWS service variables
AWS_SECRET_KEY_ID = config('AWS_SECRET_KEY_ID')
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME')
AWS_S3_CUSTOM_DOMAIN = 'd1l47x08equ47x.cloudfront.net'
AWS_S3_OBJECT_PARAMETERS = {
    'CacheControl': 'max-age=86400',
}

AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None
AWS_LOCATION = 'static'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

Nothing happens when I run collect static.

Upvotes: 1

Views: 1723

Answers (2)

femiir
femiir

Reputation: 310

i figured out django_heroku.settings(locals()) was overiding my collectstatic command and commenting the line allowed my code to work. for some reasons it will always create a default directory called staticfiles.

Upvotes: 2

Shyrtle
Shyrtle

Reputation: 647

I am not fully versed in AWS S3, but I have setup a working project and it looks like you could be missing the AWS_S3_REGION_NAME and I think that where you have AWS_SECRET_KEY_ID should be AWS_ACCESS_KEY_ID

Upvotes: 1

Related Questions