提交 cf0f3368 编写于 作者: checklate's avatar checklate

修复更新时间

上级 94fec311
...@@ -171,8 +171,9 @@ def edit(id): ...@@ -171,8 +171,9 @@ def edit(id):
if form.validate_on_submit(): if form.validate_on_submit():
post.body = form.body.data post.body = form.body.data
post.title = form.body.data.split('\n')[0].replace("# ", "") post.title = form.body.data.split('\n')[0].replace("# ", "")
post.update_timestamp = datetime.utcnow # print(datetime.now())
db.session.add(post) # post.update_timestamp = datetime.now()
# db.session.add(post)
db.session.commit() db.session.commit()
flash('The post has been updated.') flash('The post has been updated.')
return redirect(url_for('.post', id=post.id)) return redirect(url_for('.post', id=post.id))
......
...@@ -94,7 +94,7 @@ class Post(db.Model): ...@@ -94,7 +94,7 @@ class Post(db.Model):
body = db.Column(db.Text) body = db.Column(db.Text)
body_html = db.Column(db.Text) body_html = db.Column(db.Text)
timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow) timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
update_timestamp = db.Column(db.DateTime, index=True) update_timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow, onupdate=datetime.utcnow)
author_id = db.Column(db.Integer, db.ForeignKey('users.id')) author_id = db.Column(db.Integer, db.ForeignKey('users.id'))
comments = db.relationship('Comment', backref='post', lazy='dynamic') comments = db.relationship('Comment', backref='post', lazy='dynamic')
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"> <link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles.css') }}"> <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles.css') }}">
<link rel="stylesheet" href="{{ url_for('static',filename='editormd/css/editormd.css') }}"/> <link rel="stylesheet" href="{{ url_for('static',filename='editormd/css/editormd.css') }}"/>
<link rel="stylesheet" href="{{ url_for('static',filename='bootstrap-3.4.1-dist/css/bootstrap.css') }}"/>
{% endblock %} {% endblock %}
{% block navbar %} {% block navbar %}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册