search

Home  >  Q&A  >  body text

django get cannot get value - Stack Overflow

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

怪我咯怪我咯2703 days ago832

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-07-05 10:36:26

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

    reply
    0
  • Cancelreply