I have created a button which i am using to delete the selected rows
from my table. How ever i want to use an image also for each row to
delete it.. but i am unable to use. i have used a submit button which
is working to delete entries how ever my anchor tag dosen't work coz i
am not sending any key or argument or Id of the row which i want to
delete.. Please Help me How can I delete and how can i send an
argument or id of that particular row with anchor Tag...
Thanks Here is my Code
Template.html
===========
<form action="/delete_medecine/" name = "medecines" method = "POST">
<table cellspacing="0" cellpadding="0" border="0"><!-- Table -->
<thead>
<tr>
<th><input type="checkbox" class="checkall" /></th>
<th>SNo.</th>
<th>Name</th>
<th>Price</th>
<th>Quantity</th>
<th>Exp. Date</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for single in medecine_obj%}
<tr>
<td><input type="checkbox" value="{{single.id}}" name = "del_id" /
></td>
<td>{{single.id}}</td>
<td>{{single.name}}</td>
<td>{{single.price}}</td>
<td>{{single.exp_date}}</td>
<td>{{single.discription}}</td>
<td><a href="#"><img src="/login/media/assets/action_check.png"
alt="Check" /></a><a href="/delete_medecine/"><img src="/login/media/
assets/action_delete.png" alt="Delete" /></a><a href="#"><img src="/
login/media/assets/letter.png" alt="Letter" /></a></td>
</tr>
{%endfor%}
</tbody>
<a href="/medecine_form/"><input type = "button" name = "add" value =
" Add Record " alt="Add" /></a>
<input type = "submit" name = "delete" value = "Delete Records"
alt="Delete" />
views.py
=======
def delete_medecine(request,medecine={}):
print "================="
del_ids = request.POST.getlist('del_id')
Medecine.objects.filter(id__in = del_ids).delete()
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment