[Django]-Django-Compressor throws UncompressableFileError

7๐Ÿ‘

โœ…

I bumped into the same issue.

The answer was found here: https://github.com/jezdez/django_compressor/pull/206
The linkโ€™s solution is doing handler500.
I decided to change 500.html template to avoid any {{STATIC_URL}} in it and the problem was solved.

๐Ÿ‘คigo

1๐Ÿ‘

It almost looks like STATIC_URL is not in your context. You do have the staticfiles contextprocessor configured, right? Have you tried to like the file without the compressor tags? Does {{ STATIC_URL }} show up correctly in the page when you load it?

I think compressor checks the url even if it accesses it through the file system looking at https://github.com/jezdez/django_compressor/blob/develop/compressor/base.py#L57

๐Ÿ‘คubiquitousthey

1๐Ÿ‘

This is an old question, but one of the few search results when searching for this error message, so it might be worth someting to share my solution.

In my case it was a dead simple case: I hardcoded my static url and forgot the / at the beginning. So I had this:

<link type="text/css" rel="stylesheet" href="static/style.css" />

Which gave me the error. After changing to this:

<link type="text/css" rel="stylesheet" href="/static/style.css" />

It was fixed. Of course, I later realised, I should have used the setting STATIC_URL:

<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}style.css" />

Hope this helps anyone.

๐Ÿ‘คgitaarik

0๐Ÿ‘

Iโ€™ve look at it some more and Iโ€™m pretty sure the exception is caused by trying to display an uncatched error page without the full context the first pass had. This causes the exception in django-compressor.[1]

The solution, of course, is to handle all errors.

[1] Iโ€™m also running some non-standard code to display static pages, maybe this interferes and the reason that the bug is not too common.

๐Ÿ‘คBob Jansen

0๐Ÿ‘

I ran into the same issue; in my case the problem was caused by using COMPRESS_OFFLINE_CONTEXT โ€“ which does not .update() the context but it replaces it altogether, thus removing STATIC_URL.
The solution in my case was just adding it back to the COMPRESS_OFFLINE_CONTEXT, after the local_settings import, otherwise any override there wouldnโ€™t have worked.

๐Ÿ‘คpgcd

Leave a comment