django get cannot get value - Stack Overflow
怪我咯
怪我咯 2017-07-05 10:34:26
0
1
827

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')

Visit http://127.0.0.1:8888/del/316/ and the page returns none

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
曾经蜡笔没有小新

The id is passed in as a parameter. There is no need to obtain it through request.GET.get. Use the id variable directly

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template