I'm sorry, maybe I didn't explain it correctly. I have a form (not a modelform) with a modelchoicefield.
class myForm(forms.Form): recorridos = Recorrido.objects.filter(showinform=True) option = forms.ModelChoiceField(recorridos) User selects a choice, and POST. In my view, after validating it, I store firstForm.cleaned_data in session (request.session['firstForm']=firstForm.cleaned_data). Later, in other view, I want to show to the user the same form with the option he has choosen, so I do the following: secondForm = myForm(request.session['firstForm']) this don't work, because firstForm.cleaned_data cleans "option" field to Recorrido object, instead of a dict. If I store firstForm.data or request.POST in session, instead of firstForm.cleaned_data, it works correctly, because they're a dict. The question is: what is the best way of do what I want to do? I don't think it will be store firstForm.data o request.POST in session it's a good idea, so, what are the other possibilities? I 've taken a look at modelForm, but it seems to be more complicated to obtain the result I want, especially because my form don't map closely to a model. Thanks. On 22 abr, 07:09, Andy McKay <a...@clearwind.ca> wrote: > On 2011-04-21, at 4:07 PM, ekms wrote: > > > So, what is the correct way to create a bound form of > > ModelChoiceField? I could store request.POST or myform.data instead > > of myform.cleaned_data, but I don't know if this is right. > > You are confusing me when you say a bound form of a ModelChoiceField. Since > one is a form and one is a field. You can create a ModelForm given a Model > and its instance or primary key as outlined here: > > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelform > -- > Andy McKay > a...@clearwind.ca > twitter: @andymckay -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.