# 問題5 (v) ###### tags: `Flask` ## InterfaceError ``` sqlalchemy.exc.InterfaceError: <unprintable InterfaceError object> ``` :::warning 已解決 --- 將 `author=current_user._get_current_object()` 改為`author = current_user.id` --- `model` 中設定 `author = Int`,但 `current_user._get_current_object()` 會回傳 `帳號:litchiMIAU email:santa23068@gmail.com` ::: ### view ```python= @blog.route('/postedit', methods=['GET', 'POST']) @login_required def post_edit(): form = FormBlogPost() if form.validate_on_submit(): post = BlogPost( title = form.title.data, body = form.body.data, category = form.category.data, author = current_user._get_current_object(), blog = form.blog.data, slug = '{}-{}-{}-{}-{}'.format(current_user.id, datetime.now().year, datetime.now().month, datetime.now().day, slugify(form.title.data)) ) print(current_user._get_current_object()) db.session.add(post) db.session.commit() return redirect(url_for('blog.post_edit')) return render_template('blog/post_edit.html', form=form) ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up