fixed AttributeError on TEMPLATE_DEBUG=False