점프투장고 2-6 질문 있습니다.
views.py에 다음 부분이 이해가 가지 않습니다.
def answer_create(request, question_id):
"""
pybo 답변등록
"""
question = get_object_or_404(Question, pk=question_id)
question.answer_set.create(content=request.POST.get('content'), create_date=timezone.now())****
return redirect('pybo:detail', question_id=question.id)
위 내용 중 question.answer_set.create................. 에서 answer_set 이 이해가 가지 않습니다.
해당 부분이 모델에서 외래키(foreignkey)를 이용해서 Question과 Answer를 연결한 것은 알고 있습니다.
앞에 question도 위에서 get_object_or_404 를 이용해 Question을 가져온 것도 이해했습니다
그런데 answer_set은 도대체 어디서 가져온건가요??
연결된 것은 Answer인 것으로 알고 있는데 왜 소문자 answer로 쓰여진 것인지 이해가 안됩니다.
ktaemtaem 님 563
2020년 8월 7일 1:07 오후