1、修改index.html文件

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>django之创建第四个项目</title>
</head>
<body>
<h1>hello,{{test.name}}</h1> <!--模板 变量用变量定义-->
<h1>hello,{{test.sex}}</h1>
<h1>hello,{{test.where}}</h1>
</body>
</html>

2、修改views.py文件

# Create your views here.
#coding:utf-8
from django.http import HttpResponse #导入templates文件所需导入库
from django.template import loader,Context def index(request): #加载器,加载模板
t=loader.get_template("index.html") #django之创建第4-1个项目-Dict形式
user={"name":"xiaodeng","sex":"male","where":"EnShi"}
c=Context({"test":user})#在这里test位变量,user为变量的值,接收user这个字典数据
return HttpResponse(t.render(c))

3、百度云盘:http://pan.baidu.com/s/1mi1X8Mk

django之创建第4-1个项目-访问dict数据的更多相关文章

  1. django之创建第4-3个项目-访问list数据

    1.index <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...

  2. django之创建第6个项目-过滤器

    1.views.PY # Create your views here. #coding:utf-8 from django.http import HttpResponse import datet ...

  3. django之创建第12个项目-加载图片

    百度云盘:django之创建第12个项目-加载图片 1.setting配置 #静态文件相关配置 # URL prefix for static files. # Example: "http ...

  4. django之创建第11个项目-页面整合

    目的:将如下众多html页面整合到一个index.html页面中. 百度云盘:django之创建第11个项目-页面整合 用下面的方式实现: <!DOCTYPE html> <head ...

  5. django之创建第10-1个项目-图片上传并记录上传时间

    1.百度云盘:django之创建第10-1个项目-图片上传并记录上传时间 2.主要修改的配置文件有3个,forms.views和models3个文件以及html 3.forms.py文件修改 #cod ...

  6. django之创建第10个项目-图片上传方式1

    1.upload.HTMl <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang=& ...

  7. django之创建第9个项目-管理后台admin

    django之创建第9个项目-管理后台admin配置 1.配置setting文件INSTALLED_APPS = (    'django.contrib.auth',    'django.cont ...

  8. django之创建第8-3个项目-数据库数据提取之高级操作

    1.配置test2.html <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  9. django之创建第8-1个项目-数据库之增删改查/数据库数据显示在html页面

    1.为test.DB数据库预先创建下面数据 1    张三    16    2015-01-02    12    李四    17    2015-01-04    13    王五    14  ...

随机推荐

  1. Hype cycle(Gartner 成熟度曲线)

        Hype cycle The hype cycle is a branded graphical presentation developed and used by the American ...

  2. PHP导出大数据

    保存到本地 <?php // a db link for queries $lh = mysql_connect( '127.0.0.1', 'root', '' ); // and a con ...

  3. 【google chrome 一键打开 谷歌跳转的页面+JS Replace】谷歌无法打开网页的时候,提取网页中url的部分

    经常在谷歌搜索,遇到网页无法打开,然后就停留在比如:http://www.google.com.hk/search?newwindow=1&safe=strict&site=& ...

  4. 第二十七章 springboot + zipkin(brave-okhttp实现)

    本文截取自:http://blog.csdn.net/liaokailin/article/details/52077620 一.前提 1.zipkin基本知识:附8 zipkin 2.启动zipki ...

  5. Windows server 2008 SSD性能测试

    过渡到windows 7.windows8是趋势,老迈的windows xp .windows server 2003已经快到淘汰的阶段,安装了windows server 2008 R2 ,测试了下 ...

  6. ASP.NET 网站管理工具介绍

    有没有感觉对 web.config 的操作很烦呢? 老是手动来编辑 web.config 确实挺麻烦的, 不过自 ASP.NET 2.0 起便有了 ASP.NET 网站管理工具, 这个工具呢,其实就是 ...

  7. MFC如何制作字体选择对话框

    MFC封装类:CFontDialog 核心代码如下: void CGraphicView::OnFont() { CFontDialog dlg; if( IDOK == dlg.DoModal() ...

  8. css的overflow属性

    原文:https://www.jianshu.com/p/67b536fc67c1 ------------------------------------------- 事实上我挺长一段时间都没弄清 ...

  9. servlet种下cookie后如何携带cookie继续往下走

    事情是这样的,今天我在应用1里面手动种下了一个cookie,然后它会发接着访问应用2,因为是我手动setCookie,所以它还没来得及携带cookie继续前往下一站,于是,apple pen,炸了. ...

  10. HighCharts设置图表背景透明

    其实就一句话: backgroundColor: 'rgba(0,0,0,0)' 完整示例: $(function () { $('#container').highcharts({ chart: { ...