﻿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
13942	ModelChoiceField fix to_field_name fix	edcrewe	nobody	"
line 989 in http://code.djangoproject.com/browser/django/trunk/django/forms/models.py

ModelChoiceField

986    def to_python(self, value):
985 	        if value in EMPTY_VALUES:
986 	            return None
987 	        try:
988 	            key = self.to_field_name or 'pk'
989 	            value = self.queryset.get(**{key: value})
990 	        except self.queryset.model.DoesNotExist:
991 	            raise ValidationError(self.error_messages['invalid_choice'])
992 	        return value

If you supply a to_field_name argument then the value that would be used from that field name is replaced here.
Suggest replacing this with dummy object variable ...

989 object = self.queryset.get(**{key: value})

... so you get back the original field value, then this works for generating choices with different option values to labels.


"		closed	Forms	1.2		invalid	ModelChoiceField		Unreviewed	0	0	0	0	0	0
