I'm using this configuration in my settings.py
我在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?
当我部署网站时,它仍然使用s3 url而不是作为STATIC_URL提供的cloudfront url。这里有什么问题吗?
2 个解决方案
#1
1
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.
来自{% load staticfiles %}的静态命令告诉存储引擎加载静态url,其中来自{% load static %}的静态命令从设置中加载STATIC_URL。
#2
0
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.
实际上,STATIC_URL仅用于默认的staticfiles存储或根本不使用staticfiles存储时。如果设置了STATICFILES_STORAGE, django将要求该类提供有效的URL。如果要更改s3域,请使用AWS_S3_CUSTOM_DOMAIN设置。
#1
1
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.
来自{% load staticfiles %}的静态命令告诉存储引擎加载静态url,其中来自{% load static %}的静态命令从设置中加载STATIC_URL。
#2
0
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.
实际上,STATIC_URL仅用于默认的staticfiles存储或根本不使用staticfiles存储时。如果设置了STATICFILES_STORAGE, django将要求该类提供有效的URL。如果要更改s3域,请使用AWS_S3_CUSTOM_DOMAIN设置。