例外TypeError:コンテキストではなくRequestContextのより辞書でなければなりません。

TypeError例外:むしろコンテキスト最後RequestContextの中で辞書でなければなりません。
DEF指数(要求):
間違った時間を報告しました:

# 1.加载模板文件
temp = loader.get_template('booktest/index.html')

# 2. 定义模板上下文,给模板文件传递数据
# context= RequestContext(request,{})   #这样会报上面的错  错误
context = {}  #改成这样就可以了  正确

# 3. 模板渲染,产生标准的html内容
res_html = temp.render(context)

# 4.返回给浏览器
return HttpResponse(res_html)
公開された35元の記事 ウォンの賞賛0 ビュー435

おすすめ

転載: blog.csdn.net/mengzh620/article/details/103000239