﻿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
6022	m2m ValueError with form_for_instance on fresh instance	sjulean	nobody	"Assume !MyModel is a model with an m2m field. I tried this:

{{{
my_instance = MyModel(some_fk=some_value)
MyModelForm = forms.form_for_instance(my_instance)
}}}

What I got was a !ValueError telling me that i can't access m2m fields of instances that aren't saved - this was caused by a call of value_from_object from newforms/models.py:119 (in newforms-admin r6710).

Wrapping the value_from_object call in a ""try ... except !ValueError: current_value = None"" seems to have done the trick. However, I haven't submitted this as a patch, because it doesn't smell quite right. Is this the right solution? Or should value_for_object return something other than an exception for unavailable m2m field values?"		closed	Forms	newforms-admin		invalid	m2m form_for_instance		Unreviewed	0	0	0	0	0	0
