Django專案 ORM常用字段

2022-10-09 11:36:10 字數 961 閱讀 8080

orm常用字段:

1.autofield :int自增列  必須填入引數 primary_key = true    如果沒有自增列,會自動建立乙個列名為id的列

示例:class publisher(models.model):

id = models.autofield(primary_key=true) # 這是自增id

2.integerfield: 乙個整數型別,範圍在 -214783648 to 214783647

示例: age = models.integerfield() #年齡

3.charfield :字元型別,必須提供max_length引數

示例:

name = models.charfield( max_length=32, )

4.datefield :日期字段 日期格式 yyyy-mm-dd 相當於python中的datetime.date()例項

create_time =models.datefield(auto_now_add =true ) #建立時間auto_now_add =true 建立資料記錄的時候會把當前時間新增到資料庫

time =models.datefield(auto_now =true )  #更新時間  每次更新資料記錄的時候會更新這個字段

5.datetimefield :日期時間字段 格式:yyyy-mm-dd:hh:mm[:ss[.uuuuuu]][tz],相當於python中的datetime.datetime()例項

不太常用字段:

mysql 常用字段型別 mysql 常用字段型別

tinyint m unsigned zerofill 1位元組 極小整數,資料型別用於儲存一些範圍的整數數值範圍 有符號 128 127.無符號 255 特別的 mysql中無布林值,使用tinyint 1 構造。smallint 2位元組 小整數有符號 32768 無符號 65535 mediu...

django的form常用字段和引數

django 的內建字段 field required true 請求不能為空 widget none html外掛程式 label none 用於生成lable標籤或顯示內容 initial none 初始值 help text 幫助資訊 在標籤旁邊顯示 error messages none 錯...

HTTP協議常用字段

uri 統一資源識別符號,不僅可以標識http,ftp等其他的網路資源 url 統一資源定位符 get 獲取乙個資源,同時引數直接跟在url後面,url長度受限制2048位元組 post 不僅可以獲取資源,還可以提交資源 譬如上傳檔案 引數放在請求體中,包大小4g head 只要響應頭,沒有響應體,...