在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ django render不成功

django render不成功

代碼如圖
圖片描述

一直到print都是正確執(zhí)行,數(shù)據(jù)庫操作也都正確完成了,最后就是render沒有執(zhí)行,沒有報錯

回答
編輯回答
舊螢火

html 文件加上路徑

或者 第三個參數(shù)寫成 context={‘username': '', 'projects': ''}

2017年3月14日 08:14
編輯回答
乖乖瀦

render 函數(shù)的文檔:
https://docs.djangoproject.co...
render的參數(shù):
render(request, template_name, context=None, content_type=None, status=None, using=None)

  • request: 請求句柄
  • template_name: 模板名稱
  • context: 需要傳入模板中的參數(shù)
  • content_type: 返回請求頭部的content-type值,返回頁面的類型
  • status: 響應(yīng)請求的狀態(tài)碼
  • using: 用于加載模板使用的模板引擎的名稱

你最后的return 那一行需要改成:

return render(req, 'mainpage.html', contenxt={'username': 'hhhhhhh', 'projects': projects})
2017年6月8日 01:09