Django:尝试读取模板500.html时的UnicodeDecodeError

时间:2014-12-31 09:04:45

标签: python html django amazon-web-services django-templates

我正在尝试使用AWS Elastic Beanstalk将我的django应用程序部署到生产环境。在我的暂存环境中,我有DEBUG=True,一切都很好,但是DEBUG=False我收到错误UnicodeDecodeError while trying to read template /home/docker/code/django-app/templates/500.html

以下是我的500.html模板:

{% extends "base.html" %} 
{% load i18n %}

{% block title_html %}{% trans 'Server error (500)' %}{% endblock %}

{% block content %} 
    <h1>{% trans 'Server Error <em>(500)</em>' %}</h1> 
    <p>
        {% trans "There has been an error. It's been reported to the site administrators and should be fixed shortly. Thank you for your patience." %}
    </p>

{% endblock %}

1 个答案:

答案 0 :(得分:1)

可能是您的500模板未以UTF-8编码保存。由于您使用的是Komodo Edit,请尝试将其编码更改为utf8:

  

加载文件 - &gt;右键单击选项卡 - &gt;属性和设置 - &gt;文件首选项 - &gt;文件设置/编码