1. 创建主页
- 使用Django创建网页的过程通常分三个阶段:定义URL、编写视图和编写模板
- 每个URL都被映射到特定的视图,视图函数获取并处理网页所需的数据
2.编写更多视图
- 现在在
views.py
里添加更多视图
from django.http import HttpResponse
# Create your views here.
def home(request):
return HttpResponse("Hello, Welcome to Home Page")
def project_list(request):
return HttpResponse('You\'re looking at the list of project list')
def register(request):
return HttpResponse('You\'re looking at the register page')
- 把这些新视图添加进
urls
模块里
# 作者:伊洛Yiluo 公众号:伊洛的小屋
# 个人主页:https://yiluotalk.com/
# 博客园:https://www.cnblogs.com/yiluotal