loop a ChoiceField SelectMultiple form in the view as post

64 views
Skip to first unread message

dk

unread,
Jul 9, 2015, 3:21:30 PM7/9/15
to django...@googlegroups.com
i made a from

lista = (("1","one"), ("2", "two"))
pending = forms.ChoiceField(widget=forms.SelectMultiple, choices=lista)



I do get it as post method.
I do get true with is_valid()

it renders properly in the website.
but when I press the submit button.

and I am printing the form.cleaned_data["pending"]
its just empty =(
so I try  to do
for I in form.cleaned_data["pending"]
    print i
and its also empty

should I get a list out of the multiselect form? 

I just want to print all the lines that are in there.  even if they are not selected.   I want to retrieve the 1 and 2 in the view.

might be a missing part that I am not doing correct.

dk

unread,
Jul 10, 2015, 10:56:24 AM7/10/15
to django...@googlegroups.com
i might simplify lol i didnt even understand.

after i validate and clean a ChoiceField how do i us it?  
does it return a directory saying whats selected?

dk

unread,
Jul 13, 2015, 3:38:18 PM7/13/15
to django...@googlegroups.com
I made a quick project with an app,  that might be easier to see.
django_for_testing.zip

Vijay Khemlani

unread,
Jul 13, 2015, 4:20:05 PM7/13/15
to django...@googlegroups.com
To tell you the truth I'm not quite sure what are you trying to accomplish, but for starters if you have a select multiple widget then your form field should be a forms.MultipleChoiceField

On Mon, Jul 13, 2015 at 4:38 PM, dk <dem...@gmail.com> wrote:
I made a quick project with an app,  that might be easier to see.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/78297624-9cdd-4822-9dad-35de45690511%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

dk

unread,
Jul 14, 2015, 2:38:36 PM7/14/15
to django...@googlegroups.com
this is what I am trying to do.

I post what I have so far. move items between 2 multiselects. and when submit I want to retrieve what's inside each, I don't care if the items are selected or not. I just want to know what's in one and what's on the other.
that way I can do stuff with the items in one list, and do other stuff to the items in the other list.


Vijay =) I appreciate the help thanks again.
django_for_testing.zip
Reply all
Reply to author
Forward
0 new messages