On Oct 17, 1:52 pm, jacoberg2 <[EMAIL PROTECTED]> wrote:
> I am trying to create a checkbox form so that the user can delete a
> large number of
> registrations at once. I am wondering how I should set up the view in
> order to deal with
> the incoming data. Any suggestions?
The template can generate its own HTML easily enough without using a
forms.Form, e.g.
<form action="/deletethingies/" method="post">
{% for t in thingylist %}
<input type="checkbox" name="thingies" value="{{ t.id|
escape }}" />
{{ t.longname|escape }}<br/>
{% endfor %}
</form>
Then, when you're processing the POST form data, it's absolutely vital
that you call the POST.getlist('thingies') method rather than just
dereferencing POST['thingies'] !
if httpreq.POST.has_key('thingies'):
selectedthingies = httpreq.POST.getlist('thingies')
I struggled with that for quite a while when I made my first checkbox
form in Django; I was expecting a list or tuple to be right there in
the POST for me to grab directly. But nope, you gotta use the
getlist() method.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---