I have a django application with the following architecture:
skeleton/
assets/
sass/
static/
css/
templates/
base.html
settings/
common.py
dev.py
prod.py
apps/
views.py
// ...
I have a gulpfile.js
script that compile all the sass into skeleton/static/css/desktop.css
, and I have in my template skeleton/templates/base.html
:
<!DOCTYPE html>
<html>
<head>
{% load compress staticfiles %}
{% block css %}
{% compress css %}
<link href="{% static "css/desktop.css" %}" type="text/css" rel="stylesheet">
{% endcompress %}
{% endblock %}
</head>
...
My settings are:
# common.py
STATIC_ROOT = normpath(join(DJANGO_ROOT, 'static'))
STATIC_URL = '/static/'
INSTALLED_APPS = (
...
'compressor',
...
)
COMPRESS_ENABLED = True
COMPRESS_OUTPUT_DIR = 'CACHE'
This file is imported by prod
and dev
:
# prod.py
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'apps.core.storage.CachedS3BotoStorage'
STATIC_URL = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
and
# dev.py
DEBUG = True
COMPRESS_ENABLED = True
I have followed the using-staticfiles guide and implemented the CachedS3BotoStorage
(the code is exactly the same).
Locally it works fine, but as soon as I try to push it to heroku the compilation fails:
CommandError: An error occurred during rendering skeleton/templates/base.html: 'https://XXX.amazonaws.com/css/desktop.css' isn't accessible via COMPRESS_URL ('https://XXX.amazonaws.com/') and can't be compressed
Where I'm lost, is that the file https://XXX.amazonaws.com/css/desktop.css
exists (i.e. if I try to access it directly I got the file back), but somehow the compress statement does not work.
I thought that adding the CachedS3BotoStorage
file storage would help but apparently it does not.
What should I do to solve this?
Note: I have included only the minimal amount of code/config to hopefully give context, but if anything else make sense I'll add it.