Thank you, Tom. You are right! I shouldn't assign choices to a
ModelMultipleChoiceField. That's what caused the problem. But instead of
constructing a custom ModelMultipleChoiceField subclass, I abandoned "Model
Form" and simply did the following, which worked!
class myForm(forms.Form):
Question = forms.ChoiceField(choices=[], widget=forms.RadioSelect())
def __init__(self, request, *args, **kwargs):
super(myForm, self).__init__(*args, **kwargs)
self.fields['Question'].choices =
Model.objects.filter(**request.session['filter_dict']).values_list('city',
'city').distinct()
And in views.py,
def myAnswer(request):
Answer = myForm(request, request.GET or None)
if Answer.is_valid():
...........................................................
...........................................................
Once again, thank you for pointing out such important concept. It helped a
lot!
cheers,
voss
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/CVaiGVkam1QJ.
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.