博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Django | 创建和使用母版页
阅读量:2529 次
发布时间:2019-05-11

本文共 1571 字,大约阅读时间需要 5 分钟。

在Django中创建和使用MasterPages (Creating and Using MasterPages in Django)

MasterPages are a type Template that are used to implement common design across the web applications.

MasterPages是一种Template类型,用于在整个Web应用程序中实施通用设计。

Step 1: Create Sandbox, Activate it, Install Django 1.9, Create Sample Project

第1步:创建沙箱,将其激活,安装Django 1.9,创建示例项目

creating and using masterpages 1
creating and using masterpages 2
creating and using masterpages 3
creating and using masterpages 4

Step 2: Select Project Folder i.e. myapp (Outer One) and add new folder with name "templates".

步骤2:选择项目文件夹,即myapp (外部文件夹),然后添加名称为“ templates”的新文件夹。

creating and using masterpages 5
creating and using masterpages 6

Step 3: This templates folder is root location for all html templates. Add a base template i.e. base.html in this folder.

步骤3:此模板文件夹是所有html模板的根目录。 在此文件夹中添加基本模板,即base.html。

creating and using masterpages 7

Step 4: I divided Base template (Master page) into 4 Sections i.e.

步骤4:我将基本模板(母版页)分为4个部分,即

creating and using masterpages 8

Different Sections of Body Tag on base.html

base.html上身体标签的不同部分

creating and using masterpages 9
creating and using masterpages 10
creating and using masterpages 11
creating and using masterpages 12

Step 5: Add Child Pages which are inherited from base.html and add their individual contents.

步骤5:添加从base.html继承的子页面,并添加其各自的内容。

creating and using masterpages 13
creating and using masterpages 14
creating and using masterpages 15
creating and using masterpages 16
creating and using masterpages 17
creating and using masterpages 18
creating and using masterpages 19

Step 6: Add templates location to setting.py in admin app i.e. myapp (inner one)

第6步:在管理应用程序(即myapp)(内部程序)中将模板位置添加到setting.py

creating and using masterpages 20
creating and using masterpages 21

Step 7: Add Controller (i.e. views.py) in Admin App (i.e. myapp[inner one])

第7步:在Admin App(即myapp [inner one])中添加控制器(即views.py)

creating and using masterpages 22

Step 8: Add Controller Action Methods in Controller (i.e. views.py)

步骤8:在Controller中添加Controller Action Methods(即views.py)

creating and using masterpages 23

Step 9: Map routes to action methods in urls.py of admin app (i.e. myapp[inner])

第9步:在管理应用程序的urls.py(即myapp [inner])中将路由映射到操作方法

creating and using masterpages 24
creating and using masterpages 25

Step 10: Run the Server

步骤10:运行服务器

creating and using masterpages 26
creating and using masterpages 27

Step 11: Open browser and type: http://127.0.0.1:4500

步骤11:打开浏览器并输入: http : //127.0.0.1 : 4500

creating and using masterpages 28

翻译自:

转载地址:http://uzozd.baihongyu.com/

你可能感兴趣的文章
铁路信号基础
查看>>
RobotFramework自动化2-自定义关键字
查看>>
[置顶] 【cocos2d-x入门实战】微信飞机大战之三:飞机要起飞了
查看>>
BABOK - 需求分析(Requirements Analysis)概述
查看>>
第43条:掌握GCD及操作队列的使用时机
查看>>
Windows autoKeras的下载与安装连接
查看>>
CMU Bomblab 答案
查看>>
微信支付之异步通知签名错误
查看>>
2016 - 1 -17 GCD学习总结
查看>>
linux安装php-redis扩展(转)
查看>>
Vue集成微信开发趟坑:公众号以及JSSDK相关
查看>>
技术分析淘宝的超卖宝贝
查看>>
i++和++1
查看>>
react.js
查看>>
P1313 计算系数
查看>>
NSString的长度比较方法(一)
查看>>
Azure云服务托管恶意软件
查看>>
My安卓知识6--关于把项目从androidstudio工程转成eclipse工程并导成jar包
查看>>
旧的起点(开园说明)
查看>>
生产订单“生产线别”带入生产入库单
查看>>