Django: Get you started

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.