本文主要介紹數(shù)據(jù)庫配置與前端項目創(chuàng)建的關(guān)系(如何做前端數(shù)據(jù)庫),下面一起看看數(shù)據(jù)庫配置與前端項目創(chuàng)建的關(guān)系(如何做前端數(shù)據(jù)庫)相關(guān)資訊。
數(shù)據(jù)庫配置和前端項目創(chuàng)建1。封裝響應(yīng)。
utils.py/exc: def _ _ init _(self,cod: res _ data = { ;cod:代碼,;msg;:消息,} r:100,msg:成功,tok:100,msg:成功,r:101,msg:失敗} # r:101,msg:失敗}2。創(chuàng)建一個數(shù)據(jù)庫。創(chuàng)建一個數(shù)據(jù)庫。用戶向新用戶授予權(quán)限。
創(chuàng)建數(shù)據(jù)庫luffy1創(chuàng)建用戶luffy1 @ % 由 路飛 ;授予luffy1上的所有權(quán)限。*到路飛@ % ;刷新權(quán)限刷新權(quán)限;選擇用戶,host,authentication_string來自mysql.us: { ;: ;django . db . back: ;路飛 , 主持人 : ;127.0.0.1;,;post;: 3306,和;;用戶 : ;路飛1 , 密碼和密碼。;: ;路飛123 ,}} 4.下載并安裝django link數(shù)據(jù)庫的模塊。
1\使用mysqldb進(jìn)行操作- 》mysqldb不 python3.x 2之后不存在\用pymysql替換- django版本2.0.7及以上。如果用pymysql替換,需要修改django源代碼導(dǎo)入pymysqlpymysql . install _ as _ mysqldb3 \ you don ;使用mysqlclient不需要寫兩句話。
計算機(jī)編程語言../../manage.py startappuser創(chuàng)建用戶表,并基于auth展開用戶表。注意:在寫這之前,不要 不要先遷移數(shù)據(jù)。如果數(shù)據(jù)庫被遷移,這將不起作用。如果已經(jīng)遷移,刪除數(shù)據(jù)庫并刪除所有遷移文件,包括您自己的應(yīng)用程序。和兩個app #配置文件,auth和admin-registry installed _ apps =[#... 用戶 ,]# models . py class user(abstractus:移動= models . char field(max _ length = 11,unique = true) # imagefield繼承filefield,需要下載枕頭模塊icon = models . image field(upload _ to = ;圖標(biāo) ,默認(rèn)= 圖標(biāo)/默認(rèn)。;)class m: db _ tabl: return self . username # dev . py auth _ user _ model = ;用戶.用戶 #安裝pillow,遷移pip安裝pillow python manage。py makemigration python管理器。py遷移6。打開媒體文件夾界面,用戶上傳的文件會默認(rèn)保存在這里。
開發(fā)人員
媒體網(wǎng)址= /media/ ;media _ root = os . path . join(base _ dir;;媒體 )配置路由:
從django.conf導(dǎo)入設(shè)置從django.views.static導(dǎo)入serveurlpatterns =[path( ;管理/ ;,admin.site.urls),路徑( media/path :路 ,上菜,{;docum:設(shè)置。media _ root})]前臺項目創(chuàng)建1。在響應(yīng)目錄中創(chuàng)建一個vue框架項目。
事實上,vue在github中使用npm命令下載vue框架。
vue創(chuàng)建luffycity2。用pycharm打開luffycity。
3.初始化前端框架(刪除不必要的原始頁面組件)
刪除一些東西# # app.vue模板div id = app router-view//div/template # # home view . vue template div class = 家庭與娛樂h1主頁/h1 /div/ templatescript: ;homeview 、compon: { } }/script # # router index . js const routes =[{ path : ;/ ;,name : ;家庭與娛樂。;,component : homeview},] 4,下載前端框架,導(dǎo)入到vue項目中。
//elemenui,bootstrap,jquery,axios配置# axioscnpm installaxios-s # # main . js從 axios和。;vue.prototype. $ axios = axios#elementuicnpm安裝element-ui-s # # main . js從 元素-ui ;;進(jìn)口與貿(mào)易。;element-ui/lib/theme-chalk/index . css ;;vue . use(element ui);# bootstrap和jqcnpm install jquery-scnpm install bootstrap @ 3-s # # vue . config . jsconst web pack = require( 網(wǎng)絡(luò)包和);module . exports = { configurewebpack: { plugins:。provid: jqu: jqu: jqu: jqu:[ popper.js , 默認(rèn) ] }) ] }};# # main.js import 自舉 進(jìn)口與貿(mào)易。;bootstrap/dist/css/bootstrap . min . css ;5.全局css樣式配置
assets/css/global.css
/*聲明項目的全局樣式和初始化樣式*/body,h1,h2,h3,h4,h5,h6,p,table,tr,td,ul,li,a,form,input,select,option,t: 0;font-siz: 15px;}a { text-decoration:無;color: # 333;} ul { list-styl:無;}表{ border-collaps:崩潰;/*合并邊框*/}main.js文件導(dǎo)入
//將自己定義的global.css引入import 。/assets/css/global . css ;6.配置文件配置。
ass: http:// 127 . 0 . 0 . 1 : 8000 } main.js文件導(dǎo)入。
從導(dǎo)入設(shè)置 。/assets/js/settings ;vue . prototype . $ settings = settings;標(biāo)簽:
數(shù)據(jù)庫項目
了解更多數(shù)據(jù)庫配置與前端項目創(chuàng)建的關(guān)系(如何做前端數(shù)據(jù)庫)相關(guān)內(nèi)容請關(guān)注本站點(diǎn)。