﻿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
22354	ModelForm has_changed on ChoiceFields reports always True if an initial argument is given	s3h10r	nobody	"example model + form:


{{{
class Host(models.Model):
    DM=0
    PP=1
    KIND_CHOICES = (
        (DM, 'native mpio'),
        (PP, 'PowerPath'),
    )
    mpio = models.IntegerField(choices=KIND_CHOICES, default=DM)

class HostForm(ModelForm):
    DM=0
    PP=1
    KIND_CHOICES = (
        (DM, 'native mpio'),
        (PP, 'PowerPath'),
    )

    mpio = forms.ChoiceField(choices=KIND_CHOICES, label=""Multipathing Software"", required=True, initial=DM)

    class Meta:
        model = Host
}}}

testcase:

{{{
from formprob16.models import Host
from formprob16.forms import HostForm


fm = HostForm() # unbound
fm = HostForm({'mpio' : 0 }) # bound 

print ""has_changed:"", fm.has_changed()
print ""changed_data:"", fm.changed_data
}}}

output in Django 1.5.5 (and 1.4) is as expected:

{{{
>>> has_changed: False
>>> changed_data: []
}}}

output in Django 1.6.2 says the form-content was changed:

{{{
>>> has_changed: True
>>> changed_data: ['mpio']
}}}

If the initial argument is not used / the Form is just derived from the model like in the following example:

{{{
class HostForm(ModelForm):

    class Meta:
        model = Host
}}}

it works fine in 1.6.2 too, but i think that's not the expected behaviour (or: at least not expected by me ;).
 "	Bug	closed	Forms	1.6	Normal	invalid			Unreviewed	0	0	0	0	0	0
