Skip to content

HiImPeggy/DbProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DbProject

  1. 切至cmd
  2. Scripts\activate.bat
  3. 進入至虛擬環境
  4. Python manage.py runserver
  5. 查URLS

image

Menu -> 進入網站 Admin-> 進入後端 Path 中的menu是在view.py中定義的class

image

Views.py中要連結至html

image

Html在template的資料夾中

(1) 開發階段 (DEBUG=True) 首先,在開發階段時,因為static files經常性的修改,因此先讀取STATICFILES_DIRS的設定。

image

然後,這些html中要使用static資料夾內的資源,請記得加入tag。

image

(2) 佈建正式環境 (DEBUG=False) 在正式環境時,請加入STATIC_ROOT的設定,請注意STATIC_ROOT與STATICFILES_DIRS的名稱不能重複!只要Debug設為False,一定要加入這個設定,否則網頁無法正常開啟。

image

接著,請執行指令,將static裡面的資料輸出到新的資料夾staticfiles內。 python manage.py collectstatic

參考: https://chenuin.blogspot.com/2018/10/django-static-filescss-javascript-images.html

注意: (1) Setting.py中的更動

  1. 使template運作

image

2.使得static資料夾中的assets image可被使用

image

image

(2) Html中要加入 load static,連上的網站才能接收動作並回傳

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published