HTML BASE 디렉토리 지정


question_list.html

Untitled

<!DOCTYPE html>
<head>
</head>
<body>
    {% if question_list %}
        <ul>
            {% for question in question_list %}
                <li>
                    <a href="/pybo/{{ question.id }}/">{{ question.subject}}</a>
                </li>
                {% endfor %}
        </ul>
    {% else %}
        <p>
            질문이 없습니다.
        </p>
    {% endif %}
</body>
</html>

<aside> 🥕 for문을 닫을때는 endfor / if문을 닫을때는 endif

</aside>

Untitled


/pybo/질문 숫자 링크 처리

def detail(request, question_id):
    question = Question.objects.get(id=question_id)
    context = {'question' : question}
    return render(request, 'pybo/question_detail.html', context)

<aside> 🥕 **render(request, ‘pybo/question_detail.html’, context)

request 넘겨줄거야, pybo/question_detail.html한테! context 포장해서 같이 줄거야**

</aside>

<aside> 🥕 >> 결과

Untitled

<aside> 🥕 127.0.0.1/pybo config 아래의 urls.py → pybo 아래의 urls.pyviews.py index → question_list.html → pybo 아래의 urls.py 가 새로운 url 생성해서 → views.py가 id 받아서 처리 → question_detail.html

</aside>

</aside>


페이지 오류 번호