404 and 500 errors in django

Problem: Server Error 500. In the server log, all it mentions is a line that looks something like "GET / HTTP/1.1" 500 27 Potential fix: There are two potential reasons for this error. Ensure that ALLOWED_HOSTS is configured properly in the settings file. In the default settings file, there's a line for ALLOWED_HOSTS=[]. In my case, I was deploying things locally, so I edited this line to be ALLOWED_HOSTS=['127.0.01','localhost']. If you're deploying things on a specific domain, list that here. Others have suggested using ALLOWED_HOSTS=['*'], but this setting should really only be used for testing deployments, as it's not…Read more …

getting DEBUG=FALSE to work correctly

Problem: Static resources (images, js, css, etc.) lead to 404 errors. Potential fix: A similar question was posted here and here. This is actually by design, as django is not meant to server static resources when DEBUG=False. Basically, when you're in DEBUG mode, static files are being served via the staticfiles app (which uses settings like STATICFILES_DIRS and STATICFILES_FINDERS to properly locate your static resources). When DEBUG=FALSE, the staticfiles app doesn't run and your static resources aren't being referenced correctly by the django webserver. However, if you were to host the files are…Read more …

django + less, updated

In a previous post, I described how I configured the hyperkitty django project to use LESS. Briefly, my steps were: - install django-compressor, django-less, nodejs, npm, and lessc - update settings.py with configuration settings for django-compressor and django-less - restart webserver However, it turns out some of those steps are a bit outdated. First, PyPI says that django-less is not maintained and suggests using django-static-precompiler instead. Second, while LESS suggests that the easiest way to install the compiler is via npm, it is just as easy to install the LESS compiler via nodejs-less.…Read more …