Django模板应用实例templates\hello.html
来源:互联网 发布:江苏省软件考试 编辑:程序博客网 时间:2024/06/06 17:00
在 HelloWorld 目录底下创建 templates 目录并建立hello.html文件,整个目录结构如下:
hello.html 文件代码如下:
修改HelloWorld/settings.py,修改 TEMPLATES中的 DIRS为[BASE_DIR+"/templates",],如下所示:
修改view.py,增加一个新的对象,用于向模板提交数据:
render替代HttpResponse。render还使用了一个字典context作为参数。
context 字典中元素的键值 "hello"对应了模板中的变量 "{{ hello }}"。
再访问http://127.0.0.1:8000/hello/,可以看到页面:
0 0
- Django模板应用实例templates\hello.html
- django学习--templates模板
- Django学习(六)(模板templates)
- Diango学习3:Django模板应用实例
- Django学习:模板Templates(4)
- Django学习9:模板(templates)
- Django&templates
- 关于Django的模板文件的路径设置templates
- PythonWeb开发Django框架(三)模板Templates初步
- Django 框架MTV架构之Templates(模板)
- pycharm django templates css js html static文件详解
- 模板(Templates)
- Templates 模板:
- Templates 模板:
- HTML Templates
- django ajax 应用实例
- django 模板 html 分段输出
- Django模板(编写html代码
- The Falling Leaves
- m4a文件裁剪
- 异常java.lang.IllegalArgumentException: Mapped Statements collection already contains value for...
- iframe的使用
- Vijos 1117 数的划分
- Django模板应用实例templates\hello.html
- 练习2-4 重新编写函数squeeze(s1,s2),将字符串s1中任何与字符串s2中字符匹配的字符都删除。
- Android色彩矩阵——ColorMatrix
- SQOOP——Hive与MySQL数据互导
- Xshell安装教程
- Libuv中文文档序言
- Retrofit2 源码解析
- 数据库理论(1)之关系数据库设计范式
- 用VLFeat库进行k-means聚类