getlist() saved my day, thanks much :)

Cheers,
Dan

On Jul 23, 6:57 pm, rskm1 <[EMAIL PROTECTED]> wrote:
> On Jul 22, 10:16 am, "Daniel Kvasnicka jr."
>
> <[EMAIL PROTECTED]> wrote:
> > errors = form.get_validation_errors(data)
>
> > which in effect calls prepare() on every field, my data from those
> > selects are trimmed and contain only the last checked item. So when I
> > have the following choices from which I check the last two
>
> > choices = (
> >         ('0', 'foo'),
> >         ('1', 'bar'),
> >         ('2', 'hello'),
> > )
>
> > only 'hello' gets saved to the DB (MySQL 5.0.38).
>
> This might have nothing to do with the forms processing; I ran into
> the same problem with a raw html form I'd hand-constructed that had a
> set of checkboxes (same name, different values).
>
> How are you getting the data from the HTTP request when the form is
> submitted?
>
> If you call
>   httpreq.POST['choices']
> that will return a string containing only the LAST of the chosen
> items, with no indication that there's more to be had.
>
> But if you call
>   httpreq.POST.getlist('choices')
> that will return a list containing ALL of the chosen items.
>
> I think the Djangonati would recommend that you rewrite it in newforms
> (better sooner than later, right?), but I don't think that would fix
> your immediate problem anyway, if it's happening in the code where you
> process the form input into db accesses.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to