Home:ALL Converter>Django-Compress with debug=false in settings giving error

Django-Compress with debug=false in settings giving error

Ask Time:2012-07-16T20:04:25         Author:Paritosh Singh

Json Formatter

I am facing a weird problem in django. I am using django-compress app. Till debug is true everything goes all right. When I do debug=False, I face the internal server error problem in case of 404 and page without js and css in case of no 404. Worst part is, on console I am getting following error

UncompressableFileError: 'css/default.css' isn't accesible via COMPRESS_URL ('/static/') and can't be compressed [16/Jul/2012 17:17:05] "GET /static/img/favicon.ico HTTP/1.1" 500 59

Like this it shows 500 for every GET request which are accessible through /static/

So now reason for not getting js and css is clear. But reason for getting error on 404 page is not clear.

Even I tried it disabling and enabling django-compress, but on enabling even normal pages show 404 error

Please let me know what is causing 500 error for all /static/ things and why 404 page gives internal server error.

Author:Paritosh Singh,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11503906/django-compress-with-debug-false-in-settings-giving-error
Ni Xiaoni :

You can open the function of your django's email. Just modify the setting.py like below:\n\nDEBUG = False\nADMINS = (\n ('username', '[email protected]'),\n)\nEMAIL_HOST = 'smtp.gmail.com'\nEMAIL_HOST_USER = ''\nEMAIL_HOST_PASSWORD = ''\nEMAIL_PORT = 587\nEMAIL_USE_TLS = True\n\n\nAnd if happen 500, you will receive a email from your django. I hope this can help you.",
2014-04-28T03:04:15
Simeon Visser :

When DEBUG = True Django serves the static files. This means it can find the static files in the /static/ directories of each Django app. In turn, that means django-compressor can find each of the static files it needs to compress.\n\nWhen DEBUG = False Django no longer serves the static files but they should be served by the web server. It does this by serving all static files in the STATIC_ROOT directory (often /static/). That means all static files from the Django apps need to be put there.\n\nThis can be done with the collectstatic command (see The staticfiles app in the Django documentation). After you have run that command all static files should be located in STATIC_ROOT and django-compressor should be able to find the files again. That solves the 404 errors you are getting with the static files and when django-compressor works you won't get the 500 errors anymore.",
2012-07-16T12:31:09
José L. Patiño :

For Django >= 1.5, if you fall into this problem, make sure you correctly set up your ALLOWED_HOSTS setting. Don't having that setting will make Django Compressor fall into UncompressableFileError.\n\nI know we are in 2014 and this question is a bit old ;) but I fall into that problem just today, the solution for my particular case was that and it is not explained nowhere.\n\nHope it can help somebody else.",
2014-01-13T14:48:42
yy