django-compressor Offline Generation Error

2019-07-07 03:27发布

问题:

I am trying to compress my CSS files using django-compressor, but I keep receiving this error:

compressor.exceptions.OfflineGenerationError: You have offline compression enabled but key "8369f4e513fa5b733304f4b22c67ad97" is missing from offline manifest. You may need to run "python manage.py compress".

But, I have checked the manifest file and the key is in fact there.

I have already tried with and without COMPRESS_OFFLINE=True and I am not using any inline CSS.

I am not using any special Cache Backend and it is a single server setup with Django 1.7.1 and django-compressor 1.4.

My templates are setup as follows:

base.html

{% load compress %}



{% compress css %}
    {% block extraCSS %}
        <link href="/static/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
        <link href="/static/css/mimir-navbar.css" rel="stylesheet">

        <link href="/static/css/global-custom.css" rel="stylesheet">
    {% endblock %}
{% endcompress %}

and I have a few others that use base.html as follows:

{% block extraCSS %}
    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="/static/web_user/css/adminPanel.css"/>
{% endblock %}

Any ideas about what I could be doing wrong? Thanks in advance.

回答1:

It turns out my COMPRESS_ROOT path was wrong. It expects an absolute path, but my STATIC_ROOT variable was relative for some reason. Setting COMPRESS_ROOT to the absolute path of STATIC_ROOT fixed the problem.