程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

django——first lesson

編輯:Python

Self-motivated forward ,19 I began to study in django, But as the saying goes , Entry to give up . This time the journey is restarted , Never give up , come on.

A virtual environment

The following are all personal understandings , If there is any mistake, please correct it , thank you

First , We have to understand , Why do we have to use virtual environments . In fact, it is for project isolation , First, the packages used by each project are different , So these items need to be isolated , You can use a pure environment ; Second and most important , Each project may use different versions of packages ,python There is a crucial feature , Not downward compatible ( Of course, some packages are compatible ), In especial python Its own version , So separate , Not prone to interference .

however , I have to say, but . Generally, create a virtual environment , The library we use is virtualenv, but pycharm The library has been integrated , When we create a project , You can directly visualize the configuration to create a virtual environment , There is no need to create a virtual environment through instructions

A test run  

 

MTV Model  

This concept must be understood , When we write , You have to find out what you are writing , Otherwise, it is very difficult to write a page completely independently

  • M:Model, The function that program should have , Responsible for mapping business objects to databases (ORM). It can be simply understood as a database
  • T:Template, Responsible for rendering pages to users . It can be simply understood as html
  • V:View, Responsible for business logic , And call when appropriate Model and Template. It can be simply understood as an interface

The whole logic chain is as follows :

User input url-->urls Controller is responsible for distribution -->views Call the corresponding interface -->models get data -->views Get models Data in -->templates Get the data and render it to the page --> Users appreciate

This link must be able to say , This is the whole thing django Thought


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved