1(问题)
《Python编程从入门到实践》的"学习笔记"项目时,遇到的麻烦(这也正常,毕竟人家是外国的书)。
书原文
C:\learning_log\learning_logs\templates\learning_logs\topic.html 内
{% extends "learning_logs/base.html" %}
{% block page_header %}
<h3>{{ topic }}</h3>
{% endblock page_header %}
{% block content %}
<p>
<a href = "{% url 'learning_logs:new_entry' topic.id %}">Add new entry </a>
</p>
{% for entry in entries %}
<div class="card mb-3">
<h4 class="card-header">
{{ entry.date_added|date:'M d, Y H:i' }}
<small><a href = "{% url 'learning_logs:edit_entry' entry.id %}">Edit entry</a></small>
</h4>
<div class="card-body">
{{ entry.text|linebreaks }}
</div>
</div>
{% empty %}
<p>There are no entries for this topic yet.</p>
{% endfor %}
{% endblock content %}
2(解决方案)
在文件夹C:\learning_log\settings.py 内
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
改为
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False