博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
django 静态数据_如何在Django中使用静态数据?
阅读量:2528 次
发布时间:2019-05-11

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

django 静态数据

Static Data means those data items that we cannot want to change, we want to use them as it is like audio, video, images, files etc.

静态数据是指我们不想更改的数据项,我们想像音频,视频,图像,文件等那样使用它们。

Here, are the steps to create an application that will demonstrate the use of static data in Django:

以下是创建应用程序步骤,这些应用程序将演示Django中静态数据的使用

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

步骤1:创建一个沙箱,将其激活,安装Django并创建示例项目

Creating Sandbox

创建沙箱

Use static data in django 1

Activating it

激活它

Use static data in django 2

Installing Django

安装Django

Use static data in django 3

Creating Sample Project [myapp]

创建示例项目[myapp]

Use static data in django 4

Project Structure [myapp]

项目结构[myapp]

Use static data in django 5

Step 2: Add a new folder (i.e. static) in root location (i.e. myapp folder[outer])

步骤2:在根目录(即myapp文件夹[外部])中添加一个新文件夹(即静态)

Use static data in django 6

Step 3: Add Static Data (audio, videos etc) inside static folder

步骤3:在静态文件夹中添加静态数据(音频,视频等)

Use static data in django 7

Step 4: Add static folder path to settings.py of admin app (i.e. myapp[inner])

步骤4:将静态文件夹路径添加到管理应用程序的settings.py(即myapp [inner])

Use static data in django 8
Use static data in django 9

Step 5: Add a new folder templates for HTML Templates in project folder (i.e. myapp[outer])

步骤5:在项目文件夹中为HTML模板添加新的文件夹模板(即myapp [outer])

Use static data in django 10

Step 6: Add templates location to setting.py in admin app (i.emyapp[inner])

步骤6:将模板位置添加到管理应用中的setting.py(i.emyapp [inner])

Use static data in django 11
Use static data in django 12

Step 7: Add a master page (base.html) in templates folder

步骤7:在模板文件夹中添加母版页(base.html)

Use static data in django 13

Different sections of Body Tag of base.html

base.html正文标记的不同部分

Use static data in django 14
Use static data in django 15
Use static data in django 16
Use static data in django 17

Step 8: Now Add child pages (i.e. index.html, audio.html, video.html, image.html, pdf.html)

步骤8:现在添加子页面(即index.html,audio.html,video.html,image.html,pdf.html)

Use static data in django 18

Index.html

Index.html

Use static data in django 19

Audio.html

Audio.html

Use static data in django 20

Video.html

Video.html

Use static data in django 21

Image.html

Image.html

Use static data in django 22

Pdf.html

Pdf.html

Use static data in django 23

Step 9: Add a controller file (views.py) to manage views in admin app (i.e. myapp[inner])

第9步:添加控制器文件(views.py)以管理管理应用程序中的视图(即myapp [inner])

Use static data in django 24

Step 10: Add controller actions (functions) to views.py to manage requests.

步骤10:将控制器动作(功能)添加到views.py以管理请求。

Use static data in django 25

Step 11: Add new url to urls.py in admin app (i.e. myapp[inner])

第11步:在管理应用程序(即myapp [inner])中将新的url添加到urls.py中

Use static data in django 26
Use static data in django 27

Step 12: Run the Server

步骤12:运行服务器

Use static data in django 28
Use static data in django 29

Step 13: Open Browser and type http://127.0.0.1:8000

步骤13:打开浏览器并输入http://127.0.0.1:8000

Use static data in django 30
Use static data in django 31
Use static data in django 32
Use static data in django 33

翻译自:

django 静态数据

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

你可能感兴趣的文章
[PYTHON]一个简单的单元測试框架
查看>>
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>
IOS内存管理
查看>>
middle
查看>>
[Bzoj1009][HNOI2008]GT考试(动态规划)
查看>>
Blob(二进制)、byte[]、long、date之间的类型转换
查看>>
OO第一次总结博客
查看>>
day7
查看>>
iphone移动端踩坑
查看>>
vs无法加载项目
查看>>
Beanutils基本用法
查看>>