django - 字典的键值没有显示在 html 中由 django
问题描述
我刚开始学习 Django,我遇到了这个问题,我的键“hello”的键值“hello world”没有显示在 HTML 页面中,我希望你们能帮助我理解这段代码
主页.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>this is html page</h1>
{{ hello }}
</body>
</html>
网址.py
from django.urls import path
import view
urlpatterns = [
path('',view.homepage),
]
视图.py
from django.http import HttpResponse
from django.shortcuts import render
def homepage(request):
return render(request, "homepage.html", {'hello':'hello world'})
解决方案
<p>{{ hello }}</p>
在里面写你的代码
标签
推荐阅读
- java - 无法使用 ScrollPane 滚动充满标签的 VBox
- java - 使用批处理脚本中的参数运行 exe 与从应用程序运行
- javascript - 如何将上传进度条添加到Angular6中的文件上传
- r - 在 y 轴上记录和中断 (ggplot2)
- selenium-webdriver - 对黄瓜功能文件中的所有场景都使用 webDriver 的单个实例是否可以接受
- linux - 重现`名称解析中的临时失败`
- php - 查询不起作用 - 打印数组值而不是在查询中使用它
- python - 如何将超链接放入 SimpleKML?
- php - 无法从 simplexml 对象中提取数据
- google-sheets-api - 我们可以使用 Angular(或类似框架)来开发 Google Sheets Addon 吗?