Django framework and learning ---- view template (Home page with details of the jump)

URL design articles

Before we project details page article url for blog / detail, so that you can not specify a blog post, so we need to change this as follows:

blog / detail / 1 = "id for the article details page 1

blog / detail / 2 = "id for the article details page 2

blog / detail / 3 = "id for the article details page 3

blog / detail / 4 = "id for the article details page 4

blog / detail / 5 = "id for the article details page 5

Trying to perfect logic

We have now devised a good URL details page, the last URL is variable, then how do we put this variable to the path to it? See below, so that when you write path can pass in either an int variable.

 

 

 Immediately after the mapping id, we can get to the side just views.py ID, and then judged by id, remove the current ID, as shown below:

 

 Then you only need to transform the look of the home page of each article title, the title will each add a label to a

 

Guess you like

Origin www.cnblogs.com/humiao-0626/p/12656795.html