我一直在努力让Django识别我的SCSS文件(我可能会滥用SCSS / SASS / LESS术语......他们的关系让我困惑)。我正在使用django-libsass
和compress
,这两个看起来非常简单。我的页面给出了错误“资源解释为样式表,但转移了MIME类型application / octet-stream:”。它正在加载页面,但我的样式都没有显示。
我不确定人们需要看到什么。我的模板包括:
<link href="{% static 'css/blog.scss' %}" rel="stylesheet">
(当它是css时这很好用)
设定:
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'django_libsass.SassCompiler'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# other finders..
'compressor.finders.CompressorFinder',
)
答案 0 :(得分:1)
尝试将type="text/x-scss"
与压缩标记一起添加到链接元素:
{% compress css %}
<link href="{% static 'css/blog.scss' %}" rel="stylesheet" type="text/x-scss">
{% endcompress %}
确保在使用之前加载compress标记:
{% load compress %}