First time here? Check out the FAQ!

Revision history  [back]

"UndefinedError: 'settings' is undefined" exception in stactrace above happens in 500.html template. The'askbot.skins.loaders.Loader' is first loader in TEMPLATE_LOADERS. It loads 500.html(or 404, 403) template even outside of askbot app(for example in admin). Then it tries to render it, but there is no {{ settings }} in template context if current url not starts with ASKBOT_URL(see 'askbot.context.application_settings' context processor). The way to fix it is to use custom view to handle 500, 404, 403:

def view_500(request):
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        template_name = 'errors/500.html'
    else:
        template_name = '500.html'

    return defaults.page_not_found(request, template_name=template_name)

In urls.py:

handler500 = 'your_app.views.view_500'

We move our error templates for all apps to 'error/' subfolder in template folder. In this case askbot template loader can't find it and templates will be loaded using next loader in TEMPLATE_LOADERS - standard Django loader. Thus, we have separate error templates for our apps and for askbot. But it's still an ugly hack :)