First, the development environment:
Python:2.7;pycharm 4
Second, the Django installation:
Open Pycharm-- New project--See diagram-- automatically install the Django environment
Third, create the first website:
1.① Open Views.py② Import ③ write an index function (first written in hard-coded form)
2.① Open urls.py ② imported function ③ Add a new item to the Urlpatterns array
3. Locate the Start button in the upper-right corner and click
4. Locate and click the URL to open the Web page
After opening
Now we enter the new URL: http://127.0.0.1:8000/blog/
"Parse" matches theexpression path in the URL (r ' ^blog/$ ', index) and finds the corresponding index function to handle
5. Now, create a new index.html file in the Templates directory and add the following code
6. Next, ① open views.py ② Modify the code before the import module ③ comments ④ New index function (parameter for our new HTML file name)
7. Finally, we refresh the page to see
"parsing" was preceded by a hard-coded string, and this time we returned a static page
So we can build a website.
Django: Get you started