一、HttpResponse与JsonResponse

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("T
Django响应对象详解
本文主要介绍了Django的HttpResponse、JsonResponse和FileResponse。HttpResponse是返回给浏览器的响应对象,包含content、charset、status_code等属性。JsonResponse专门用于返回JSON格式的内容。FileResponse则用于发送文件内容。在返回模板方面,重点讲解了render方法及其参数,如request、template_name、context等。
订阅专栏 解锁全文
6404

被折叠的 条评论
为什么被折叠?



