점프 투 플라스크 댓글 기능, 인자 문의 드립니다.
선생님 안녕하세요
인자라고 해야하는게 맞는지 모르겠네요
용어를 잘 몰라서요 양해 부탁드립니다.
3-11 댓글 기능 추가하기에서
- 답변 댓글 등록, 수정, 삭제 함수 추가하기
내용중에
답변의 댓글을 수정하는 modify_answer 함수 문의 드립니다
@bp.route('/modify/answer/<int:comment_id>', methods=('GET', 'POST'))
@login_required
def modify_answer(comment_id):
comment = Comment.query.get_or_404(comment_id)
if g.user != comment.user:
flash('수정권한이 없습니다')
return redirect(url_for('question.detail', question_id=comment.answer.id))
if request.method == 'POST':
form = CommentForm()
if form.validate_on_submit():
form.populate_obj(comment)
comment.modify_date = datetime.now() # 수정일시 저장
db.session.commit()
return redirect(url_for('question.detail', question_id=comment.answer.question.id))
else:
form = CommentForm(obj=comment)
return render_template('comment/comment_form.html', form=form)
위 코드중에서
return redirect(url_for('question.detail', question_id=comment.answer.id))
여기서
question_id=comment.answer.id
question_id를 comment.answer.id 를 주는 게 맞나요?
question_id는 질문 유저 아이디 이고
answer.id 는 답변 유저 아이디 인데
아무리 생각해도 이해가 안갑니다.ㅠㅠ
답변주시면 감사하겠습니다.
ilue00 님 563
2021년 9월 11일 11:41 오후
1개의 답변이 있습니다. 1 / 1 Page
comment.answer.id 가 아니라 comment.answer.question.id 가 맞습니다.
책이 잘못되었네요.. ㅜㅜ
책의 내용은 수정하겠습니다.
알려주셔서 감사합니다.
박응용 님
2021년 9월 12일 12:01 오전