django中的Response和HttpResponse有什么区别我有点混乱。
from rest_framework.response import Response
Return Respose
和
from django.http import HttpResponse
return HttpResponse
答案 0 :(得分:0)
HttpResponse-> SimpleTemplateResponse->响应
代码:
"""
The Response class in REST framework is similar to HTTPResponse, except that
it is initialized with unrendered data, instead of a pre-rendered string.
The appropriate renderer is called during Django's template response rendering.
"""
class Response(SimpleTemplateResponse):
"""
An HttpResponse that allows its data to be rendered into
arbitrary media types.
"""
答案 1 :(得分:0)
如果没有阅读文档,就不应该使用库。
响应来自Django Rest Framework,而不是Django,并且fully documented就在那里。