Reputation: 426
I am using digitalocean.com spaces to store static files for my Django app. I set it up successfully according to their tutorial (same settings as AWS). I now want to put a CDN in front of the static files. KeyCDN has a document describing how to do this but suggests using {{STATIC_URL}}
in templates rather than the {% static %}
templatetag.
Django admin uses the {% static %}
templatetag not {{ STATIC_URL}}
. In some cases there is no difference, however, if you define STATICFILES_STORAGE
, as is required to store static files in digitalocean.com spaces, the templatetag {% static %}
ignores whatever you explicitly declare in settings.py for STATIC_URL
.
I have:
STATICFILES_STORAGE='storages.backends.s3boto3.S3Boto3Storage'
S3Boto3Storage
sets the template tag {% static %}
to point to https://ams3.digitalocean.com/bucket_name/path/to/static/
regardless of the setting of {{ STATIC_URL }}
.
Manually setting STATIC_URL=
in settings.py
as KeyCDN suggests:
STATIC_URL = 'http://keycdndjango-1c6b.kxcdn.com/static/'
has no effect on what the templatetag {% static %}
returns.
So i cannot figure out how to make KeyCDN work with this setup.
Any help is appreciated!
Upvotes: 2
Views: 288
Reputation: 11
Well, I don't know if this was the case, but I'm using Digital Ocean CDN and setting AWS_S3_ADDRESSING_STYLE to 'virtual' made the change
from
https://ams3.digitalocean.com/bucket_name/path/to/static/
to
https://bucket_name.ams3.digitalocean.com/path/to/static/
Upvotes: 1