忽略在夹层中压缩的外部源

时间:2018-05-01 09:39:00

标签: python django mezzanine django-compressor

在联系表单模板夹层中加载外部源,夹层

实施例

{% block extra_js %}
{{ block.super }}    
    <script src="https://www.google.com/recaptcha/api.js" async defer></script>
{% endblock %}

压缩程序异常

compressor.exceptions.UncompressableFileError: 'https://www.google.com/recaptcha/api.js' isn't accessible via COMPRESS_URL ('/static/') and can't be compressed

1 个答案:

答案 0 :(得分:1)

将脚本标记放在{%extra_head%}块中,而不是{%extra_js%}块中。如果您查看基本模板,您会看到{%extra_js%}中的所有内容都通过{%compress%}进行压缩:

https://github.com/stephenmcd/mezzanine/blob/bec6595fc960013aaa4d590d842acff6d206f20b/mezzanine/core/templates/base.html#L34-L39

相关问题