Django响应(一)

一、HttpResponse与JsonResponse

Django响应(一)_第1张图片

1.1、HttpResponse

官网:https://docs.djangoproject.com/zh-hans/4.1/ref/request-response/#django.http.HttpResponse

返回给浏览器端的响应对象

from django.http import HttpResponse
response = HttpResponse("Here's the text of the web page.")
response = HttpResponse("Text only, please.", content_type="text/plain")
response = HttpResponse(b'Bytestrings are also accepted.')

属性

    你可能感兴趣的:(Django,django,python,后端)