Maison > Questions et réponses > le corps du texte
views.py
def Del_table(request,id):
if request.method == 'GET':
nid = request.GET.get('name.id')
return render(request,'del.html',{'nid':nid})
del.html
{{nid}}
table.html
<tr>
<td style="word-wrap:break-word" width="5%" align="center" >{{ name.id }}</td>
<td style="word-wrap:break-word" width="5%" align="center" >{{ name.name }}</td>
<td style="word-wrap:break-word" width="5%" align="center" >{{ name.author }}</td>
<td style="word-wrap:break-word" width="5%" align="center" >{{ name.serialstatus }}</td>
<td style="word-wrap:break-word" width="5%" align="center" >{{ name.category }}</td>
<td style="word-wrap:break-word" width="40%" align="center" >{{ name.introduction }}</td>
<td style="word-wrap:break-word" width="40%" align="center" >
<p><a href="/edit/{{name.id}}" >Edit</a></p>
<p><a href="/del/{{name.id}}">Del</a> </p>
<p> <a href="/add/{{name.id}}">Add</a> </p>
</td>
</tr>
urls.py
url(r'^del/(?P<id>\d+)/$',ve.Del_table,name='del')
Visitez http://127.0.0.1:8888/del/316/ et la page ne renvoie aucun
曾经蜡笔没有小新2017-07-05 10:36:26
L'identifiant est transmis en paramètre. Il n'est pas nécessaire de l'obtenir via request.GET.get. Utilisez directement la variable id
.