文章目錄
-
-
-
-
- 1. 在項目根目錄下建立`templates` 檔案夾,用來存放模闆檔案
- 2. 配置settings檔案
- 3. 寫一個簡單的HTML頁面
- 4. teacher APP下視圖檔案
- 5. teacher APP 下路由
- 6. 通路頁面
-
-
-
1. 在項目根目錄下建立 templates
檔案夾,用來存放模闆檔案
templates
templates裡再建立一個teacher檔案夾,用來存放teacher APP下的HTML檔案
2. 配置settings檔案
讓系統能夠找到templates路徑
3. 寫一個簡單的HTML頁面
4. teacher APP下視圖檔案
from django.shortcuts import render, redirect, reverse
from django.http import HttpResponse
# Create your views here.
def index(request):
# 通過render渲染模闆
return render(request, 'teacher/index.html')
5. teacher APP 下路由
from django.urls import path, re_path
from . import views
app_name = 'teacher'
urlpatterns = [
path('index/', views.index),
]