﻿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
22097	IntegerField with given choices leads to wrong has_changed() work	igor.mitrenko@…	Claude Paroz	"It seems that providing choices to IntegerField makes ModelForm (created by admin, for example) to use ChoiceField and call it's to_python method, which return string. Finally, _has_changed method compares initial value (of type int) to new value (of type unicode), and always returns True.
My code sending ""object created"" signals on each inline object change, so it leads to creation of unnecessary ""changed"" events logging.

Snippet:
{{{
...
class PhoneNumber(models.Model):
    """"""
    Phone number set for workers
    """"""
    MOBILE_PHONE = 0
    WORK_PHONE = 1
    HOME_PHONE = 2
    KIND_CHOICES = (
        (MOBILE_PHONE, _('Mobile')),
        (WORK_PHONE, _('Work')),
        (HOME_PHONE, pgettext('kind of phone number', 'Home')),
    )
    worker = models.ForeignKey(Worker)
    phone_number = models.CharField(_('phone number'), max_length=12)
    kind = models.SmallIntegerField(_('kind of number'), choices=KIND_CHOICES, default=MOBILE_PHONE)
...
}}}
ModelForm derived from such a model created ChoiceField for kind, but it's has_changed method return True always, cause it's (as example) always 1 != u'1'

Removing choices argument is a workaround, but it breaks desired behaviour. 
Another workaround is to use CharField, but the problem still remains.
Django version 1.7.dev20131210091409"	Bug	closed	Forms	1.7-alpha-1	Release blocker	fixed			Accepted	0	0	0	0	0	0
