Django框架介绍 中英文双语计算机专业毕业设计外文文献翻译成品(最新)Word文件下载.docx
《Django框架介绍 中英文双语计算机专业毕业设计外文文献翻译成品(最新)Word文件下载.docx》由会员分享,可在线阅读,更多相关《Django框架介绍 中英文双语计算机专业毕业设计外文文献翻译成品(最新)Word文件下载.docx(54页珍藏版)》请在冰豆网上搜索。
![Django框架介绍 中英文双语计算机专业毕业设计外文文献翻译成品(最新)Word文件下载.docx](https://file1.bdocx.com/fileroot1/2022-10/7/c8dc09ae-b34d-4769-bf26-275ae8d5d7c7/c8dc09ae-b34d-4769-bf26-275ae8d5d7c71.gif)
一辈子也就一次的事!
外文标题:
IntroductiontotheDjangoFramework
外文作者:
DanielRubio
文献出处:
DanielRubio.IntroductiontotheDjangoFramework[M].BeginningDjango.2017:
1-29(如觉得年份太老,可改为近2年,毕竟很多毕业生都这样做)
英文8701单词,40127字符(字符就是印刷符),中文12987汉字。
TheDjangoframeworkstartedin2003,asaprojectdonebyAdrianHolovatyandSimonWillisonattheJournal-WorldnewspaperinLawrence,Kansas,intheUnitedStates.In2005,HolovatyandWillisonreleasedthefirstpublicversionoftheframework,namingitaftertheBelgian-FrenchguitaristDjangoReinhardt.
Fastforwardto2017–theDjangoframeworknowoperatesundertheguidanceoftheDjangoSoftwareFoundation(DSF),theframeworkcorehasover1000contributorswithmorethan15releaseversions,andthereareover3000packagesspecificallydesignedtoworkwiththeDjangoframework.1
TheDjangoframeworkhasremainedtruetoitsoriginsasaModel-View-Controller(MVC)server-sideframeworkdesignedtooperatewithrelationaldatabases.Nevertheless,Djangohasstayeduptodatewithmostwebdevelopmenttendencies–viathird-partypackages–tooperatealongsidetechnologieslikenon-relationaldatabases(NoSQL),real-timeInternetcommunication,andmodernJavaScriptpractices.Allthistothepoint,theDjangoframeworkisnowthewebdevelopmentframeworkofchoiceforawidearrayoforganizations,includingthephotosharingsitesInstagram2andPinterest3;
thePublicBroadcastingSystem(PBS)4;
intheUnitedStates,NationalGeographic5;
andwiththehelpofthisbook,yourorganization!
Inthischapteryou’lllearnabouttheDjangoframeworkdesignprinciples,whicharekeytounderstandingtheday-to-dayaspectsofworkingwiththeDjangoframework.Next,you’lllearnhowtoinstallDjangoinvariousways:
asatar.gzfile,withpip,usinggit,andwithvirtualenv.
OnceyouinstalltheDjangoframework,you’lllearnhowtostartaDjangoprojectandhowtosetitupwitharelationaldatabase.Next,you’lllearnaboutthecorebuildingblocksintheDjangoframework–urls,templates,andapps–andhowtheyworkwithoneanothertosetupcontent.Finally,you’lllearnhowtosetuptheDjangoadminsite,whichisaweb-basedinterfacedesignedtoaccesstherelationaldatabaseconnectedtoaDjangoproject.
DjangoFrameworkDesignPrinciples
Ifyouworklongenoughinwebdevelopment,you’lleventuallycometotheconclusionthatyoucanproducethesameresultswithjustaboutanywebframeworkandprogramminglanguage.Butwhileyoucan,infact,produceidenticalresults,whatwillvarydrasticallyisthetimeyouspendcreatingasolution:
thetimecreatingaprototype,thetimeaddingnewfeatures,thetimedoingtesting,thetimedoingdebugging,andthetimedeployingtoscale,amongotherthings.
Inthissense,theDjangoframeworkusesasetofdesignprinciplesthatproducesoneofthemostproductivewebdevelopmentprocessescomparedtomanyotherwebframeworks.Note,I’mnotsayingDjangoisasilverbullet(e.g.,thebestatprototyping,themostscalable);
I’msayingthatattheendoftheday,theDjangoframeworkincorporatesasetofdesignprinciplesandtrade-offsthatmakeitoneofthemostproductiveframeworksforbuildingthefeaturesneededbymostmediumtolargewebapplications.Now,whileyoumightthinkI’mbiased–afterallI’mwritinganentirebookaboutthetopic–I’lllayoutthesedesignprinciplesfirst,soyoucangainabetterunderstandingofwhatgivestheDjangoframeworkthisedge.
Don’tRepeatYourself(DRY)Principle
Repetitionmightbegoodtoemphasizeapoint,butwhenitcomestowebdevelopment,itjustleadstoadditionalandtime-consumingwork.Infact,theverynatureofwebdevelopment,whichoperatesacrossmultipletiersinteractingwithoneanother(e.g.,HTMLtemplates,businesslogicmethods,anddatabases),lendsitselftorepetition.
TheDjangoframeworkreallytriestoforceyounottorepeatyourself,solet’sseehowDjangoenforcesnotrepeatingyourselfandwhythisisagoodthing.Let’ssayyouwanttobuildacoffeehouseapplicationtopublishinformationaboutstoresandalsohaveacontactformforcustomers.Thefirstthingyou’llneedtodoisdeterminewhatkindofinformationisrequiredforstoresandthecontactform.Figure1-1illustratesamock-upoftwoDjangomodelsforeachoftheseentities.
Figure1-1.Djangomodelsforstoreandcontactentities
NoticehowtheDjangomodelsinFigure1-1eachhavedifferentfieldnamesandadatatypetorestrictvalues.Forexample,thestatementname=models.CharField(max_length=30)tellsDjangoastorenameshouldhaveamaximumof30characters,whilethestatementemail=models.EmailField()tellsDjangothecontactentityshouldcontainavalidemailvalue