Sudhanshu Mishra
Sudhanshu Mishra

Reputation: 2094

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?

Upvotes: 9

Views: 923

Answers (2)

Sudhanshu Mishra
Sudhanshu Mishra

Reputation: 2094

I fixed this with a change in the templates.

static from {% load staticfiles %} tells the storage engine to load the static url where as static from {% load static %} simply loads the STATIC_URL from the settings.

Upvotes: 0

GwynBleidD
GwynBleidD

Reputation: 20539

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.

Upvotes: 10

Related Questions