﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7457	newforms ModelChoiceField accepts id only	vomjom@…	nobody	"Using newforms:
{{{
class StepForm(forms.Form):
    procedure = forms.ModelChoiceField(Procedure.objects.all())

...
foo = StepForm(request.POST)
}}}

foo.cleaned_data will look like:
{{{
{'procedure': <Procedure: example procedure>}
}}}

Which means the cleaned_data has an instance of a Model.  That's fine.

But when passing data to a newforms
{{{
foo = StepForm({'procedure': some_procedure_instance})
}}}

It won't work.  You must instead do:
{{{
foo = StepForm({'procedure': some_procedure_instance.id})
}}}

There are a few reasons I think this is a bug:
 1. It would make more sense if cleaned_data and the data argument to a newforms.Form matched up.  It'd be nice if newforms.Form allowed both models.Model or an id.
 2. If you're using FormSets from the newforms-admin branch, you can't do this code (this adds more forms, as necessary, to a FormSet):
{{{
old_formset = StepFormSet(request.POST, request.FILES)
formset = StepFormSet(initial=old_formset.cleaned_data)
}}}
Because the cleaned_data contains the instances whereas the newforms.Form requires an id."		closed	Forms	dev		duplicate		vomjom@…	Design decision needed	0	0	0	0	0	0
