基於Python搭建Django後台管理系統

2021-08-20 22:54:01 字數 1332 閱讀 2473

django-admin startproject helloworld

進入該專案

cd helloworld

建立乙個子專案

生成站點(sites)model,這兩步驟第一篇有介紹,這裡就直接操作了 

python manage.py createsuperuser
這步很關鍵,你每次修改model裡面的資料,都要從復執行這下面這幾個步驟:

'django.contrib.admin',

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.messages',

'django.contrib.staticfiles',

'django.contrib.sites'

]執行終端命令

之前模型model中寫了乙個方法 def str(self):這個是舊版本中用的方法,django新版本要換成def unicode(self):, 這樣就解決了字串傳遞時出錯的問題,統一編碼為unicode字串。

operationalerror no such table / operationalerror table sites_article has no column named test

這是一類錯誤,就是我之前提醒的,我們增加model或者修改models.py裡面的**後,需要從新執行步驟五,步驟五的作用就是更新資料庫表的資訊,比如你新增model中的乙個字段,沒有更新資料庫表,自然會報上面的錯誤 

解決方法:執行步驟五的終端命令

python manage.py makemigrations

python manage.py migrate

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後台管理系統

一 部落格 的建立 之後,我們執行一下專案,輸入 看一下效果 三 資料庫後台搭建 到登入頁基本完成一半啦,接下來就需要建立乙個管理員賬戶用於登入使用,3.將model新增到sites admin.py裡 4.執行一下專案,開啟管理介面,檢視效果,然後你就看隨意新增article內容啦 六 踩坑總結 ...