Django學習筆記2

2021-10-05 08:42:37 字數 703 閱讀 9882

路由

檢視函式

瀏覽器訪問 一級路由+二級路由

常用的屬性

例子

from django.db import models

# db database 資料庫

# models 模型

# 學生表的 用類驅動資料

class

user

(models.model):id

= models.autofield(primary_key=

true

) name = models.charfield(max_length=

32,unique=

true

) age = models.integerfield(default=18)

status = models.booleanfield(default=

false

) addtime = models.datetimefield(auto_now_add=

true

)

生產遷移檔案

python manage.py makemigrations講遷移檔案資訊入庫

python manage.py migrate之後 你在你的資料庫中就可以看到乙個新生成的資料表 應用名+類名(小寫) 的一張資料表

Django學習筆記2(模板)

這一輪的學習主要是為了掌握django中關於模板的使用,為了開發與維護的高效,必然將要採取模組分離的方法,因此,html檔案最好不要直接硬編碼python,而是html頁面和python 單獨各位一塊,由一些鏈結的橋梁來將html載入到 之中.所以這段時間所學習的模板,其實就是為了達到這個目的,通常...

Django學習筆記第2記

一 模板 1 模板渲染 python manage.py shell from django.template import template,context template定義形式,context定義內容 t template c context print t.render c render為...

django學習筆記 day2

概述 language code zh hans time zone asia shanghai from django.contrib import admin register your models here.from models import grades,students 註冊 admi...