pythondjangomezzaninedjango-compressor

Ignore external sources being compressed in mezzanine


Tring to load external source in contact form template, mezzanine

Example

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

Compressor exception

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

Solution

  • Put the script tag inside the {% extra_head %} block instead of the {% extra_js %} block. If you look at the base template you'll see everything in {% extra_js %} gets compressed via {% compress %}:

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