liang@l:~$ source .bashrc
用makemigration和migrate命令創(chuàng)建默認(rèn)數(shù)據(jù)庫(kù),自動(dòng)創(chuàng)建的用戶表為==auth_user== 再次打開(kāi)數(shù)據(jù)庫(kù)的users_profile表,顯示創(chuàng)建成功 3.3 user models.py設(shè)計(jì) User models.py 和Courses models.py存在循環(huán)引用 解決循環(huán)import最常用的方法是分層設(shè)計(jì): 1. django app設(shè)計(jì) 2. users models.py編寫 3. courses models.py編寫 4. organization models.py編寫 5. operaion models.py編寫(最上層) 形成以下結(jié)構(gòu)圖: 3.3.3 organization models.py 設(shè)計(jì) 課程機(jī)構(gòu)結(jié)構(gòu)如下: 1. CourseOrg - 課程機(jī)構(gòu)基本信息 2. Teacher - 教師基本信息 3. CityDictionary - 城市信息 3.3.4 operation models.py 設(shè)計(jì)結(jié)構(gòu): 1. UserAsk - 用戶咨詢 2. CourseComments - 用戶評(píng)論 3. UserFavorite - 用戶收藏 4. UserMessage - 用戶消息 5. UserCourse - 用戶學(xué)習(xí)的課程 設(shè)計(jì)代碼如下: 3.3.5 數(shù)據(jù)庫(kù)生成以及apps目錄建立 打開(kāi)manage.py task 此時(shí)每個(gè)app文件夾下會(huì)生成migrations文件夾
然后執(zhí)行==右擊apps文件夾 > Mark Directory as > Sources Root==,這樣,在根目錄下找不到的表可以在apps目錄下繼續(xù)尋找,但是這樣仍然不夠,在命令行下運(yùn)行python manage.py runserver 時(shí),仍然會(huì)報(bào)錯(cuò)找不到users |
|
來(lái)自: 長(zhǎng)沙7喜 > 《編程》