Django Compressor, OfflineGenerationError and 500.html (handler500)

If you’ve tried using Django Compressor in your 500.html error handler you’ve most likely run into an error similar to the following in your logs:

From the docs… “The default 500 view passes no variables to the 500.html template and is rendered with an empty Context to lessen the chance of additional errors.”

This presents a slight problem if you’re using any type of assets (CSS, images, etc.) in your 500 page as you now have to maintain separate versions just for your 500.html instead of using the ones being generated by Compressor.

The solution is to use a custom class-based view. First, create a new view in your application:

Now tell Django to use it by declaring handler500 in your URLconf:

One thought on “Django Compressor, OfflineGenerationError and 500.html (handler500)”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s