django模板的使用方法
2015-09-12 21:07
671 查看
模板有三种使用方法
views
views
from django.template import loader, Context, template from django.http import HttpResponse from django.shortcuts import render_tp_response def index1(req): t = loader.get_template('index.html') c = Context({'usename':'jlan'}) return HttpResponse(t.render(c)) def index2(req): t = Tempate('<h1>hello, {{username}}</h1>') #创建模板 c = Context({'username':'jlan'}) return HttpResponse(t.render(c)) def index3(req): return render_to_response('index.html', {'username':'jlan'})
相关文章推荐
- Django Web开发指南的坑
- Week1-6Analysis of Algorithm Introduction
- Baskets of Gold Coins
- django 常用 模板过滤器
- golang gRPC示例
- Baskets of Gold Coins 2401 (简单数学题)
- hdoj 2401 Baskets of Gold Coins
- Google浏览器设置搜索打开新的标签页
- Google浏览器设置搜索打开新的标签页
- Google浏览器设置搜索打开新的标签页
- Google浏览器设置搜索打开新的标签页
- golang timestamp
- golang md5及随机字符串
- golang 子类调用父类函数
- exact algorithm 精确算法
- HD 2041 Baskets of Gold Coins
- HDOJ 2401 Baskets of Gold Coins(数学,等差数列求和)
- Baskets of Gold Coins
- django复习笔记1:环境配置
- golang获取字符串长度需要注意的地方