Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STATIC_URL is being overridden while using django-storages in Django 1.8

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?

like image 294
Sudhanshu Mishra Avatar asked Feb 12 '16 18:02

Sudhanshu Mishra


People also ask

What is Static_url in Django?

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 .

What is staticfiles_ STORAGE in Django?

staticfiles_storage is a callable within the django. contrib. staticfiles. storage module of the Django project.

How does Django storages work?

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.

What is Staticfiles_dirs?

STATICFILES_DIRS is the list of folders where Django will search for additional static files aside from the static folder of each app installed.


1 Answers

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.

like image 112
GwynBleidD Avatar answered Oct 09 '22 23:10

GwynBleidD