PhoneGap中文网
标题:
Django 学习之模板变量
[打印本页]
作者:
w8484855@qq.com
时间:
2017-8-12 14:29
标题:
Django 学习之模板变量
本文和大家分享的主要是django中模板变量相关内容,一起来看看吧,希望对大家
学习django
有所帮助。
1.传入普通变量
在hello/Hello World/temlplates/index.html中,修改html文件
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>{{title}}</title>
<meta charset="utf-8">
</head>
<body>
<h1> Hello {{name}}</h1>
</body>
</html>
接着在hello/Hello World/views.py文件中,修改views.py
from django.shortcuts import render
def index(request):
return render(request,'index.html',{'title':'Welcome','name':'KeinLee'})
然%
欢迎光临 PhoneGap中文网 (http://bbs.phonegap100.com/)
Powered by Discuz! X3.2