我正在尝试使用 AWS Elastic Beanstalk 将我的 django 应用程序部署到生产环境。在我的暂存环境中,我有 DEBUG=True
,一切都很好,但是当 DEBUG=False
时,我在尝试读取模板/时收到错误 UnicodeDecodeError首页/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 %}
最佳答案
可能是你的500模板没有以UTF-8编码保存。由于您使用的是 Komodo Edit,请尝试将其编码更改为 utf8:
Load the file -> right-click on the tab -> properties & settings -> File Preferences -> File Settings/Encodings
关于python - Django:尝试读取模板 500.html 时出现 UnicodeDecodeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27718720/