I. Django INTRODUCTION
Django is a good heavyweight web framework written by Python, open source, using MVC's software design pattern, i.e. model M, view V and Controller C.
Second, under Windows environment installation
1, installation
You need to install Python first in this article to install Python 2.7.13 (), install the tick pip and add path to environment variables,
Installation complete, go to command line pip install django==1.8.2, pip install Mysql-python,pip install Pillow
2, create a Django test project
Create a directory Djangoproject directory on the desktop, switch to this directory on the command line, or double-click to open this directory and hold down SHIFT right-click on the command line:
650) this.width=650; "title=" 1.png "src=" https://s3.51cto.com/wyfs02/M02/9E/A0/wKioL1mT_57zR_ Tvaaczot-i4ks109.png-wh_500x0-wm_3-wmp_4-s_722691159.png "alt=" Wkiol1mt_57zr_tvaaczot-i4ks109.png-wh_50 "/>
in the Command Window , enter the command to create the Django project (django-admin) _
Note the configuration of the environment variables, will be python under the installation directory Scripts the path to the directory is added to the Path Environment Variables
650) this.width=650; "title=" 2.png "src=" https://s3.51cto.com/wyfs02/M00/9E/A0/wKioL1mUAATSOqYQAAANbsv2itg350.png "alt=" Wkiol1muaatsoqyqaaanbsv2itg350.png "/>
This opens the directory structure with Pycharm as follows:
650) this.width=650; "title=" 3.png "src=" https://s4.51cto.com/wyfs02/M00/9E/A0/wKioL1mUAC_ Dm3wraaaufxwww-e598.png-wh_500x0-wm_3-wmp_4-s_3120000558.png "alt=" wkiol1muac_dm3wraaaufxwww-e598.png-wh_50 "/ >
Description
Test [Django project directory]
- Test [Django root file directory ]
-__init__.py[ make current directory a package ]
-settings.py [ project configuration file ]
-urls.py [web Routing ]
-wsgi.py[ file for production environment deployment)
manage.py [ Project control file ]
3. Run the test project
Switch to the directory where manage.py runs Python manage.py runserver (the default is to listen on 127.0.0.1:8000 if you need to listen on all IPs can 0.0.0.0:port)
650) this.width=650; "title=" 4.png "src=" https://s4.51cto.com/wyfs02/M00/9E/A1/wKioL1mUASDiPxZwAAAvC7KM1So564.png "alt=" Wkiol1muasdipxzwaaavc7km1so564.png "/>
4. Visit 127.0.0.1:8000
650) this.width=650; "title=" 5.png "src=" https://s2.51cto.com/wyfs02/M00/9E/A1/ Wkiol1muavmtfmywaaccpguqnf8841.png-wh_500x0-wm_3-wmp_4-s_1083083936.png "alt=" Wkiol1muavmtfmywaaccpguqnf8841.png-wh_50 "/>
5. First Test page Hello Word
Create views.py under the urls.py sibling directory and write the code that Django does not carry views.py code as follows:
650) this.width=650; "title=" 6.png "src=" https://s2.51cto.com/wyfs02/M00/9E/A1/wKioL1mUAiCSTH-jAAAgmKx4UmE211.png "alt=" Wkiol1muaicsth-jaaagmkx4ume211.png "/>
Modify urls.py
650) this.width=650; "title=" 7.png "src=" https://s5.51cto.com/wyfs02/M01/9E/A1/wKioL1mUAlWApPR4AAAeHeyNz3k472.png "alt=" Wkiol1mualwappr4aaaeheynz3k472.png "/>
View results: Http://127.0.0.1:8000/index
650) this.width=650; "title=" 8.png "src=" https://s5.51cto.com/wyfs02/M01/9E/A1/wKioL1mUAtvCpfaBAAAVft3qr3Q426.png "alt=" Wkiol1muatvcpfabaaavft3qr3q426.png "/>
Here under Windows based on the Python 2.7.13 django1.8.2 environment deployment is complete.
Iii. Installing the Django environment under Ubuntu16.04
The Python 2.7.12 and 3.5.2 versions are installed by default in 1,ubuntu 16.04, but the system uses 2.7 by default to install Pip
Also install pip install django==1.8.2;pip install Mysql-python;pip Install Pillow
2, install MySQL
#apt-get Install Mysql-server
The installation process will only prompt for the root password
#apt-get Install mysql-client Libmysqlclient-dev
3, other operations are similar to Windows, not detailed here
This article is from the "Learning, learning" blog, please be sure to keep this source http://dyc2005.blog.51cto.com/270872/1956870
python2.7x Django MySQL environment built under windows Ubuntu