Cases:
We created a table like this in the template:
You can see that since then there are 2 actions: Modify and delete
In Django we can do this without JavaScript and Ajax,
<a href= "{% url ' list_delete ' i.id%}" > Delete |</a> here the i.id is generated through a tabular loop, specifically the ID primary key for the backend database, which we first Make a variable to see if we click Delete or modify on line 4th, its value is 4<a href= "{% url ' list_modify ' i.id%}" > Modify </a>
We define the path to the 2 URLs in the template and add the IDs of the databases later,
' List_delete '
We're going to be in the urls.py. The URL name that is defined in the
urls.py
URL (r ' ^index/list_modify/(? p<i_id>\d+)/$ ', list_modify,name= ' list_modify '), url (r ' ^index/list_delete/(? p<i_id>\d+)/$ ', list_delete,name= ' list_delete '),
We've defined this so that a URL will be generated later
/INDEX/LIST_MODIFY/4/can look at the above picture, we chose the 4th line, the 4 in the URL is assigned to the I_ID, the specific regular expression can be searched under
At last, I quote this variable in view.py.
def list_modify (request,i_id):
django1.7 use of {%url%} in HTML templates