﻿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
3140	"""float argument required"" exception in admin_list"	nick@…	Adrian Holovaty	"I get the following exception in the admin app when trying to view a list of objects with a float field in the list_display options:

Exception Type:  	TypeError
Exception Value: 	float argument required
Exception Location: 	/usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_list.py in items_for_result, line 155

However, I don't get this error on my development server which is running SQLite (my ""production"" server is running MySQL).

The code in question:

{{{
152 	            # FloatFields are special: Zero-pad the decimals.
153 	            elif isinstance(f, models.FloatField):
154 	                if field_val is not None:
155 	                    result_repr = ('%%.%sf' % f.decimal_places) % field_val
156 	                else:
157 	                    result_repr = EMPTY_CHANGELIST_VALUE
}}}

If I add a float() around the field_val it fixes the problem, e.g.:

{{{
152 	            # FloatFields are special: Zero-pad the decimals.
153 	            elif isinstance(f, models.FloatField):
154 	                if field_val is not None:
155 	                    result_repr = ('%%.%sf' % f.decimal_places) % float(field_val)
156 	                else:
157 	                    result_repr = EMPTY_CHANGELIST_VALUE
}}}

It looks like the MySQL backend is returning a string for the field_val or something?"	defect	closed	contrib.admin	dev	normal	duplicate			Unreviewed	0	0	0	0	0	0
