I'm using this configuration in my settings.py
INSTALLED_APPS += ('storages',)
AWS_STORAGE_BUCKET_NAME = config.AWS_STORAGE_BUCKET_NAME
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATIC_URL = '//xyz.cloudfront.net/'
When I deploy the website, it still uses the s3 url instead of the cloudfront URL provided as STATIC_URL
. Is there something wrong here?
STATIC_URL is simply the prefix or url that is prepended to your static files and is used by the static method in Django templates mostly. For more info, read this. STATIC_ROOT is the directory or location where your static files are deployed when you run collectstatic .
staticfiles_storage is a callable within the django. contrib. staticfiles. storage module of the Django project.
The django-storages is an open-source library to manage storage backends like Dropbox, OneDrive and Amazon S3. It's very convenient, as it plugs in the built-in Django storage backend API. In other words, it will make you life easier, as it won't drastically change how you interact with the static/media assets.
STATICFILES_DIRS is the list of folders where Django will search for additional static files aside from the static folder of each app installed.
STATIC_URL
is actually only used by default staticfiles storage or when staticfiles storage is not used at all. If STATICFILES_STORAGE
is set, django will ask that class to provide valid URL. If you want to change your s3 domain, use AWS_S3_CUSTOM_DOMAIN
setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With