0
MongoDbから結果を取得し、jinjaテンプレートに渡すという簡略な方法が見つかりました。 フラスコのジンジャーの日付フィールドが正しく表示されます
@app.route('/home')
def home():
table = mongo.db.posts
result = table.find({ }).sort([("postdate", 1)])
records = json.loads(json_util.dumps(result))
if result.count() > 0:
return render_template('users/index.html', posts=records)
else:
message = 'I couldn't find any post'
return render_template('users/index.html', message=message)
そしてユーザー/ index.htmlをに私はこのような結果を表示したいと思い
:日付フィールドを除いて、予想通り{% for post in posts %}
<tr>
<td>{{post._id}}</td>
<td>{{post.title}}</td>
<td>{{post.author}}</td>
<td class="date">{{post.postdate}}</td>
</tr>
{% endfor %}
すべてが動作します。日付フィールドを正しく表示する方法はありますか?
{'$date': 1508227970796}
{'$date': 1508228089163}
{'$date': 1508241780398}