错误:无法解析字符串中的rfc1738 URL。我认为我已经尝试了一切,但无法解决。
app.config['SQLALCHEMY_DATABASE_URI'] = 'C:/dev/FlaskBlog/blog.db'
db = SQLAlchemy(app)
class Blogpost(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(50))
subtitle = db.Column(db.String(50))
author = db.Column(db.String(20))
date_posted = db.Column(db.DateTime)
content = db.Column(db.Text)
当我尝试发表文章时出现问题。
这是加邮路线:
@app.route('/addpost', methods=['POST'])
def addpost():
if request.method == 'POST':
title = request.form['title']
subtitle = request.form['subtitle']
author = request.form['author']
content = request.form['content']
post = Blogpost(title=title, subtitle=subtitle, author=author, date_posted=datetime.now())
db.session.add(post)
db.session.commit()
return redirect(url_for('index'))
else:
return render_template('index.html')
答案 0 :(得分:0)
SQLALCHEMY_DATABASE_URI 应该是有效的 db uri,修复它,它应该可以工作。我也遇到了同样的问题。