Fom view to template:
I think there are several ways but this is the one I'm using:
return render_to_response('index.html', {'user' : request.user,
'form' : f,
'latestEntries' : booksSorted[0:5],
'toDateEntries': booksToDate,
'calendar': mark_safe(cal), },
context_instance=RequestContext(request))
In the template you will be able to acces user, form, ....
Template to view:
You either post the values or use the URL to pass them on.
If you post them you can acces request.Post in the view, which will give you a dict that contains the values.
If you use the URL you have to configure urls.py adequate. (covered in the doc, sry i dont have the time right now to explain this further)
Hope this helps...
. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
XSLT Developer
LexisNexis
Marxergasse 25, 1030 Wien
mailto:patrick.szabo@lexisnexis.at
Tel.: 00431 534521573
Fax: +43 (1) 534 52 - 146
-----Ursprüngliche Nachricht-----
Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im Auftrag von Showket Bhat
Gesendet: Donnerstag, 01. September 2011 12:38
An: Django users
Betreff: How To send arguments Along with Calling an .Html page
Hi All..
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.
--
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