﻿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
15126	Misleading error in ModelForm	ingo@…	nobody	"Hi,

setting the fields attribute in the Meta-class of a ModelForm to a tuple with only one value specified (without the trailing ',') results in a string. After expiriencing hours of bugtracking i mentioned this fact. The django code in this case doesnt exactly point out, whats causing the problem, because a string as a fields-attribute value also is an iterable object, so it iterates over every single character of this string(handling every charactar as a field) and finaly raises a AttributeError ('ΝοneType' object has no attribute 'widget') when calling the is_valid() method.
It was unnecessarily complicated to recognize the cause for this exception. After this i found, that the python-docs (http://docs.python.org/tutorial/datastructures.html#tuples-and-sequences) also mention this 'ugly' issuse to be fixed by appending a ','.
Perhaps the django-code should help people saving thier time in this case and evaluate if the fields-attribute contains a string or a valid tuple. One solution would be to convert a string to a list or to raise a more meanigful error. Another approach could be a more explicit hint in the ModelForm-Documentation(by mentioning the error it would cause not appending a ',').
"	Bug	closed	Forms	1.2	Normal	fixed	modelform fields attributeerror widget subset	bmispelon@…	Accepted	1	0	0	0	0	0
