python - 上下文不呈现我的 html 页面 - django
问题描述
所以观点是:
def username(request):
context = {}
if request.POST:
pass
else:
context['title'] = 'type a username'
return render(request, 'update/one-input.html', context)
然后在html页面中:
<h5>{{ title }}</h5>
当我运行该页面时,它没有给我任何错误,并且它没有在标题内显示任何想法我在页面的另一个视图中执行相同的代码及其工作,为什么在这个视图中不起作用,那么问题是什么?):
解决方案
我认为您需要将最后一行更改为:
return render(request, 'update/one-input.html', {'context': context})
然后在你的html
你将拥有context
它的所有内容。
推荐阅读
- sql - 可以在运行时调用过程中使用case语句吗
- accessibility - 如何处理屏幕阅读器的版本号?
- android - 录制屏幕时的Android方向问题
- ram - Nand闪存芯片;x8 和 x16 位的 I/O 宽度?
- python - Q 值太高,值变为 NaN,Q-Learning Tensorflow
- php - 如何在这个 PHP 脚本中添加序列号列?
- python - Python中的投注赔率组合
- visual-studio-code - 如何在 VSCode 终端中发送 SIGQUIT 或 SIGKILL
- javascript - React Native UseState 数组清除
- python - spacy lemmatizing 与 lemma_lookup 表不一致