-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
version : Django==1.11.29
原文描述:
执行完上述方法, 并且Django帮我们执行完view, 拿到最终的 response 后, 如果使用了模板的 response (这里指通过 return render(request, 'index.html', context={}) 方式返回的 response), 就会来到这个方法中.
实际测试后发现:
def index(request):
students = Student.get_all()
form = StudentForm()
context = {
"students": students,
"form": form,
}
return render(request, 'index.html', context=context)
# return TemplateResponse(request, "index.html", context=context)- 执行上述代码, 只会进入middleware的
process_response方法; - 执行
return TemplateResponse(request, "index.html", context=context)而非return render(request, 'index.html', context=context)才会进入process_template_response方法中
这是我的发现, 欢迎大家指出我过程中是否存在问题导致和 书籍 中 描述的结论不符.
Metadata
Metadata
Assignees
Labels
No labels