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
创建沙箱
Activating it
激活它
Installing Django
安装Django
Creating Sample Project [myapp]
创建示例项目[myapp]
Project Structure [myapp]
项目结构[myapp]
Step 2: Add a new folder (i.e. static) in root location (i.e. myapp folder[outer])
步骤2:在根目录(即myapp文件夹[外部])中添加一个新文件夹(即静态)
Step 3: Add Static Data (audio, videos etc) inside static folder
步骤3:在静态文件夹中添加静态数据(音频,视频等)
Step 4: Add static folder path to settings.py of admin app (i.e. myapp[inner])
步骤4:将静态文件夹路径添加到管理应用程序的settings.py(即myapp [inner])
Step 5: Add a new folder templates for HTML Templates in project folder (i.e. myapp[outer])
步骤5:在项目文件夹中为HTML模板添加新的文件夹模板(即myapp [outer])
Step 6: Add templates location to setting.py in admin app (i.emyapp[inner])
步骤6:将模板位置添加到管理应用中的setting.py(i.emyapp [inner])
Step 7: Add a master page (base.html) in templates folder
步骤7:在模板文件夹中添加母版页(base.html)
Different sections of Body Tag of base.html
base.html正文标记的不同部分
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)
Index.html
Index.html
Audio.html
Audio.html
Video.html
Video.html
Image.html
Image.html
Pdf.html
Pdf.html
Step 9: Add a controller file (views.py) to manage views in admin app (i.e. myapp[inner])
第9步:添加控制器文件(views.py)以管理管理应用程序中的视图(即myapp [inner])
Step 10: Add controller actions (functions) to views.py to manage requests.
步骤10:将控制器动作(功能)添加到views.py以管理请求。
Step 11: Add new url to urls.py in admin app (i.e. myapp[inner])
第11步:在管理应用程序(即myapp [inner])中将新的url添加到urls.py中
Step 12: Run the Server
步骤12:运行服务器
Step 13: Open Browser and type http://127.0.0.1:8000
步骤13:打开浏览器并输入http://127.0.0.1:8000
翻译自: https://www.includehelp.com/Django/how-to-use-static-data-in-django.aspx
django 静态数据