一、创建项目
二、项目结构
三、hello.py
from django.shortcuts import render
def hello(request):
context = {}
context['hello'] = 'Hello World!'
return render(request, 'hello.html', context)
四、urls.py
from django.conf.urls import url
from django.contrib import admin
from hello import hello
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^hello/', hello.hello),
]
五、hello.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hello</title>
</head>
<body>
<h1>{{ hello }}</h1></body>
</html>
六、启动
七、访问