Tuesday, August 30, 2011

Unable To Delete Records

Hi All...

I have created a small application where in i am inserting and
deleting records. I am able to delete a single record however when a
select all or more then one record it deletes the last record only.. I
tried a lot but failed please help I am wring the Code and the Console
output here....

my function to delete a medecine from its table in views.py

def delete_medecine(request,medecine={}):
print "------>>",request.POST
list = []
for i in request.POST['del_id']:
m = Medecine.objects.get(id = i)
return HttpResponseRedirect('/medecine')

my template file

<form action="/delete_medecine/" name = "medecines" method = "POST">
<table cellspacing="0" cellpadding="0" border="0"><!-- Table -->

<th><input type="checkbox" class="checkall" /></th>
<th>Exp. Date</th>

{% for single in medecine_obj%}
<td><input type="checkbox" value="{{single.id}}" name
= "del_id" /></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 href="/medecine_form/"><input type = "button" name = "add"
value = " Add Record " alt="Add" /></a>
<input type = "submit" name = "delete" value = "Delete Records"
alt="Delete" />


My Console

DeprecationWarning: CsrfResponseMiddleware and CsrfMiddleware are
deprecated; use CsrfViewMiddleware and the template tag instead (see
CSRF documentation).
================================== <QueryDict:
{u'csrfmiddlewaretoken': [u'fea796e4bc7836bb8584140b71a0afcc'],
u'del_id': [u'1', u'2', u'8'], u'delete': [u'Delete Records']}>
===== 8
[30/Aug/2011 06:04:56] "POST /delete_medecine/ HTTP/1.1" 302 0


Please help

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