Django template. The href parameter in HTML is passed in

Source: Internet
Author: User

In a Django template, access to multiple URLs may appear to point to the same function, and to reduce the code can be implemented using regular expressions

URL (r ' ^remove_userinfo (? P<nid>\d+)/', views.removeuserinfo,name= ' reinfo '),

(? p<nid>\d+) indicates that the name of this section is nid, corresponding to the NID parameter in Removeuserinfo (Request,nid)

def Removeuserinfo (Request,nid):     return HttpResponse (NID)

In this case, the value of the href in the a tag in HTML can be written as {% url "reinfo" row.id%}

<hrefurl "reinfo" row.id%} class= "btn Btn-link"  ID = "Remove{{row.id}}" > Delete </a>

Where Reinfo corresponds to the name in the URL (see first code), row.id as the parameter nid passes through the URL to the Removeuserinfo (Request,nid)

Django template. The href parameter in HTML is passed in

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.