0
該問題的ID進行比較後顯示從數據庫記錄是IM不能從HREF 比較ID之後以顯示edit_vendor.html記錄PLZ giude有人 我有views.py就像我怎麼能與HREF
def vendor(request,id):
key = request.GET.get('id')
obj = Vendor.objects.get(id = key)
return render_to_response('edit_vendor.html',{'obj': obj},context_instance=RequestContext(request))
模板
<a href ='/vendor/{{vendor.id}}/'> edit </a>
edit_vendor.html
{% for Vendor in obj %}
<tr>
<form action="/update/" method="get">
Vendor Name:<input type ='text' name= 'name' value ={{Vendor.name}}></br>
Address: <input type ='text' name= 'address' value = {{Vendor.address}}></br>
Contact:<input type = 'text' name= 'contact' value = {{Vendor.contact}}></br>
Created Date <input type ='text' name='date' value = {{Vendor.created_date}}></br>
<input type='submit' name='Submit' value='update' />
</form>
</tr>
{% endfor%}
嘗試'OBJ = Vendor.objects.get(ID = ID)',而不是當前'OBJ = Vendor.objects.get(ID =鍵)' – okm 2013-02-26 09:52:05
完美..!非常感謝 – raghu 2013-02-26 09:57:38