django 静态数据_如何在Django中使用静态数据?
django 靜態(tài)數(shù)據(jù)
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.
靜態(tài)數(shù)據(jù)是指我們不想更改的數(shù)據(jù)項(xiàng),我們想像音頻,視頻,圖像,文件等那樣使用它們。
Here, are the steps to create an application that will demonstrate the use of static data in Django:
以下是創(chuàng)建應(yīng)用程序的步驟,這些應(yīng)用程序?qū)⒀菔綝jango中靜態(tài)數(shù)據(jù)的使用 :
Step 1: Create a Sandbox, Activate it, Install Django and Create Sample Project
步驟1:創(chuàng)建一個(gè)沙箱,將其激活,安裝Django并創(chuàng)建示例項(xiàng)目
Creating Sandbox
創(chuàng)建沙箱
Activating it
激活它
Installing Django
安裝Django
Creating Sample Project [myapp]
創(chuàng)建示例項(xiàng)目[myapp]
Project Structure [myapp]
項(xiàng)目結(jié)構(gòu)[myapp]
Step 2: Add a new folder (i.e. static) in root location (i.e. myapp folder[outer])
步驟2:在根目錄(即myapp文件夾[外部])中添加一個(gè)新文件夾(即靜態(tài))
Step 3: Add Static Data (audio, videos etc) inside static folder
步驟3:在靜態(tài)文件夾中添加靜態(tài)數(shù)據(jù)(音頻,視頻等)
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}Step 4: Add static folder path to settings.py of admin app (i.e. myapp[inner])
步驟4:將靜態(tài)文件夾路徑添加到管理應(yīng)用程序的settings.py(即myapp [inner])
Step 5: Add a new folder templates for HTML Templates in project folder (i.e. myapp[outer])
步驟5:在項(xiàng)目文件夾中為HTML模板添加新的文件夾模板(即myapp [outer])
Step 6: Add templates location to setting.py in admin app (i.emyapp[inner])
步驟6:將模板位置添加到管理應(yīng)用中的setting.py(i.emyapp [inner])
Step 7: Add a master page (base.html) in templates folder
步驟7:在模板文件夾中添加母版頁(yè)(base.html)
Different sections of Body Tag of base.html
base.html正文標(biāo)記的不同部分
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}Step 8: Now Add child pages (i.e. index.html, audio.html, video.html, image.html, pdf.html)
步驟8:現(xiàn)在添加子頁(yè)面(即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)以管理管理應(yīng)用程序中的視圖(即myapp [inner])
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}Step 10: Add controller actions (functions) to views.py to manage requests.
步驟10:將控制器動(dòng)作(功能)添加到views.py以管理請(qǐng)求。
Step 11: Add new url to urls.py in admin app (i.e. myapp[inner])
第11步:在管理應(yīng)用程序(即myapp [inner])中將新的url添加到urls.py中
Step 12: Run the Server
步驟12:運(yùn)行服務(wù)器
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 靜態(tài)數(shù)據(jù)
總結(jié)
以上是生活随笔為你收集整理的django 静态数据_如何在Django中使用静态数据?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 创建bootstrap项目_使用Boot
- 下一篇: 秦时丽人明月心剧情介绍