Django | 创建和使用母版页

news/2024/7/10 3:04:39 标签: python, django, vue, html, js
htmledit_views">

在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

翻译自: https://www.includehelp.com/Django/creating-and-using-masterpages.aspx


http://www.niftyadmin.cn/n/1254490.html

相关文章

python怎么成为高手_如何成为Python高手

性能你会看到有如此多的讨论都在批评这些“脚本语言”(Python,Ruby)是如何的性能低下,可是你却经常的容易忽略这样的事实:是程序员使用的算法导致了程序这样拙劣的表现。这里有一些非常好的文章,能让你知道Python的运行时性能表现…

java now_Java即时类| now()示例方法

java nowInstant Class now()方法 (Instant Class now() method) Syntax: 句法: public static Instant now();public static Instant now(Clock cl);now() method is available in java.time package. now()方法在java.time包中可用。 now() method is used to ge…

控制台css定位,自动化测试-6.selenium的css定位

前言大部分人在使用selenium定位元素时,用的是xpath定位,因为xpath基本能解决定位的需求。css定位往往被忽略掉了,其实css定位也有它的价值,css定位更快,语法更简洁。这一篇css的定位方法,主要是对比上一篇…

Python | 检查文件是否存在?

The task is to check whether a file exists or not? 任务是检查文件是否存在 ? Before continuing to the tutorial, please note that – there are some of the separate functions which are used to check whether a file or directory exists or not. So y…

python多线程下载视频_python 实现多线程下载m3u8格式视频并使用fmmpeg合并

电影之类的长视频好像都用m3u8格式了,这就导致了多线程下载视频的意义不是很大,都是短视频,线不线程就没什么意义了嘛。我们知道,m3u8的链接会下载一个文档,相当长,半小时的视频,应该有接近千行…

任务分配问题 背包问题_努力与不努力的任务问题

任务分配问题 背包问题Problem statement: 问题陈述: A list of n days is given to you and there are three columns. One is the day, the second one is high-effort value, and the another one is low-effort value. At a time you can pick only one either…

java ssh 服务器文件,java ssh linux上传文件到服务器上

java ssh linux上传文件到服务器上 内容精选换一换安装传输工具在本地主机和Windows云服务器上分别安装数据传输工具,将文件上传到云服务器。例如QQ.exe。在本地主机和Windows云服务器上分别安装数据传输工具,将文件上传到云服务器。例如QQ.exe。本地磁盘…

c# uri.host_C#| 带示例的Uri.Fragment属性

c# uri.hostUri.Fragment属性 (Uri.Fragment Property) Uri.Fragment Property is instance property of Uri class which used to get a un-escaped fragment from URI. This property returns a string value. This property may generate System.InvalidOperationException …