HttpResponse 对象 ¶ class HttpResponse ¶ 与由Django自动创建的 HttpRequest 对象相比, HttpResponse 对象由程序员创建.你创建的每个视图负责初始化实例,填充并返回一个 HttpResponse . HttpResponse 类是在 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" )