Django – HttpResponse() 예제

간단한 결과 확인을 위한 HttpResponse 예제를 하나 정리해둔다.

공식 사이트는 여기 => https://docs.djangoproject.com/en/4.2/ref/request-response/#httpresponse-objects

def index_page(request):
    latest_question_list = Company.objects.order_by("-created_at")[:5]
    response = HttpResponse()
    response.write("<p>Here's the text of the web page.</p>")
    response.write("<p>Here's another paragraph.</p>")
    for item in latest_question_list:
        response.write("<p>")
        response.write(item)
        response.write("</p>")
    return response

Share: Twitter Facebook
Bongjun Hur's Picture

About Bongjun Hur

BJ is a dev.

Seoul, Korea https://devbj.com