Step 1.1: Install python, configure the Python environment
Python download directory: https://www.python.org/downloads/mine is window7 install the Windows x86-64 Executable installer version. Reference Links: https://jingyan.baidu.com/article/0bc808fc42dfab1bd485b99f.html, note Configuring the Python environment
Step 1.2: Install Pycharm reference: https://jingyan.baidu.com/article/72ee561a59694be16138df3a.html
Step 1.3: Install Django, I tried two methods, after installation, please put C:\Program Files\python36\lib\site-packages\django; C:\Program files\python36\lib\site-packages\django\bin; Add environment variable, this is my installation directory, here are two ways:
The first is a if configure Pyhton environment, directly open cmd, input pip install Django
The second opens the Pycharm and selects the default setting for the File menu
Double-click the right area, pop-up, enter the Third-party library you need, click on the install package below, most of the Python Third-party libraries can be installed in this way
The installation environment is now configured to complete.
Let's go to the first Web configuration tour
Step 2.1: In a DOS environment, enter the directory where you want to put the project, use django-admin.py to create the project, for example, I want to create a Hello World project under D:\, then I enter the DOS environment into the d:\ Execute the following command: django-admin.py startproject Hello World as follows:
After successful execution, a HelloWorld folder is generated under D:\
Step 2.2 Open this project with Pycharm
File-->open--> Select D:\helloworld as shown:
So, opened the HelloWorld this project
Step 2.3. As shown in the diagram configuration, run this project.
After saving, run directly, this project will be able to run up.
SETP 2.4 Next create the first app. Execute DOS command in the project's directory: django-admin.py Startapp SayHello, you will create a SayHello app in the project's folder, as shown:
At the same time we can see this app in Pycharm, we can write our code in the views.py file in the SayHello folder: Add the following code:
datetime
httpresponseSayHello (Request):
httpresponse (' Hello world! ')
Then modify the urls.py file in the project folder, add the URL (R ' ^sayhello/', SayHello), map to the urlpatterns, and then restart our project and enter the http://in the browser 127.0.0.1:8000/syahello will see our results.
So far we have built a Pycharm+django development environment