﻿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
21224	TypedChoiceField does not properly coerce 'None' in certain circumstances	anonymous	nobody	"{{{
class MyModelAdmin(admin.ModelAdmin):
	def formfield_for_dbfield(self, db_field, **kwargs):
		if db_field.name == 'integerfield':
			return forms.TypedChoiceField(choices=((None,'Undecided'),(-1, 'Reject'), (0, 'Neutral'), (1,'Accept')))
}}}

Selecting 'Undecided' here results in the error message ""'None' must be an integer""

In order to fix this I have to add the following param to TypedChoiceField:

{{{coerce=lambda v: int(v) if v and v != 'None' else None}}}

If I try this instead it results in the error ""Select a valid choice. None is not one of the available choices."":

{{{coerce=lambda v: int(v) if v else None}}}

It appears that the None choice is getting coerced to a string before it passes into TypedChoiceField.to_python (or wherever it gets passed to first)?"	Uncategorized	closed	Database layer (models, ORM)	1.5	Normal	worksforme			Unreviewed	0	0	0	0	0	0
