django之创建第3个项目:编写第一个模板文件
2016-04-04 21:12
525 查看
1、django结构
2、在站点blog下创建templates文件夹,专门用于存放模板文件
3、在templates文件夹下创建index.html文件
#index.html
4、修改views.py文件
2、在站点blog下创建templates文件夹,专门用于存放模板文件
3、在templates文件夹下创建index.html文件
#index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>第一个模板文件</title> </head> <body> <h1>django之创建第三个项目:编写第一个模板文件</h1> </body> </html>
4、修改views.py文件
# Create your views here. #coding:utf-8 from django.http import HttpResponse #导入templates文件所需导入库,注意没有s from django.template import loader,Context def index(request): #第二个项目 #return HttpResponse("hello,Django") #加载器,获取一个模板 t=loader.get_template("index.html") c=Context({})#没有写入数据,只是单纯的加载了index.html文件 return HttpResponse(t.render(c))
相关文章推荐
- SwipeRefreshLayout google自带下拉刷新
- 【VK Cup 2016 - Round 1 (Div 2 Edition)C】【构造】Bear and Forgotten Tree 3 构造一棵树直径为d且点1的深度为h
- django之创建第2个项目
- 如何从Google Play下载应用到电脑?
- UVa-10618 Tango Tango Insurrection&& UVa-1627 Team them up!
- django之创建第1个项目并查看网页效果
- UVa 11292&HDU1902 The Dragon of Loowater (贪心)
- Oh,mygoddess
- POJ 3107 Godfather(树形DP)
- django之环境变量配置
- 读Nature文章,看AlphaGo养成
- 1003 Hangover(数学水题)
- IPhone怎么打开Google和instagram还有facebook呢?
- Ten sort algorithms in interviews
- 在Windows下编译mongo-c-driver 1.3.x
- Light OJ 1106 Gone Fishing (DP)
- OC中Category的注意点
- 我与Django
- Django如何测试视图
- Django Admin 管理工具, 以及问题解决