工程结构
views.py
# -*- coding: utf-8 -*-
from django.shortcuts import render
def home(request):
string = u"我在学习Django,用它来建网站"
return render(request, 'home.html', {'string': string})
url.py
home.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>显示一个基本的字符串在网页上</title>
</head>
<body>
<h1>{{ string }}<h1>
</body>
</html>
页面展示效果: