django 静态数据_如何在Django中使用静态数据?

这篇博客介绍了如何在Django中使用静态数据,包括创建沙箱、安装Django、设置静态文件夹路径、添加HTML模板、创建母版页和子页面、管理视图以及配置URL,最后通过运行服务器并在浏览器中查看效果。
摘要由CSDN通过智能技术生成

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

翻译自: https://www.includehelp.com/Django/how-to-use-static-data-in-django.aspx

django 静态数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值