Python 網頁開發 Django 學習筆記

2021-09-24 12:34:54 字數 1246 閱讀 7545

1.安裝django

pip install django 或者是通過 「==」符號指定版本號

2.建立乙個django專案

django-admin startproject projectname(django舊版本指令django-admin createproject projectname已移除)

3.django專案中的檔案

manage.py 管理**的配置檔案,settings.py 管理專案配置,urls.py 路由,views.py 檢視,module.py 模型類

4.每次更改完**配置,django會主動檢測並載入更新

5.

manage.py的使用

使用runserver的方式啟動專案:python manage.py runserver ip:port ,如: python manage.py runserver 127.0.0.1:8080,利用ip可以訪問不在同乙個主機的資料庫

同步(遷移)資料庫:建立乙個應用:啟動互動介面:python manage.py shell

檢測模組中是否有錯誤:python manage.py checkdjango舊版本指令python manage.py validate 已移除

的sql語句(包括索引):建立超級使用者:manage.py createsuper --username=joe [email protected]

設定django時區:修改time_zone='asia/shanghai',然後重啟就ok了

8.在預設情況下django使用sqlite資料庫儲存資料。

9.建立資料庫: python manage.py makemigrations 。 同步資料庫: python manage.py migrate

10.models.py檔案中每個類對應資料庫中每乙個表,變數對應字段。

python的django介紹 Django 簡介

django 簡介 自強學堂的django教程將節省你大量的時間,並且使你的web開發充滿樂趣。通過django,你可以建立乙個高效能的web應用而只花費最少的時間和精力。django 中提供了開發 經常用到的模組,常見的 都為你寫好了,通過減少重複的 django 使你能夠專注於 web 應用上有...

python考勤系統 使用Djang的考勤系統

型號attendance choices absent absent present present class head of department models.model first name models.charfield max length 200 last name models.c...

如何用python開發網頁

我們將為這個專案指定規範,然後為應用程式使用的資料定義模型。我們將使用django的管理系統來輸入一些初始資料,再編寫檢視和模板,讓django能夠為我們的 建立網頁。django是乙個web框架 一套用於幫助開發互動式 的工具。django能夠響應網頁請求,還能讓你更輕鬆地讀寫資料庫 管理使用者等...