﻿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
16138	ModelForm's 'initial' attribute unexpectedly persists across different instances	Haisheng HU	nobody	"There are two !UpdateView's (or !CreateView's) A and B with their corresponding !ModelForm A and B. From !UpdateView A the 'initial' attribute in !ModelForm A was set to a certain value. After this, !UpdateView B and !ModelForm B were created. Now the 'initial' attribute in !ModelForm B was not {}, but the '''same''' as !ModelForm A.

{{{
class UpdateViewA(UpdateView):
    model = Project
    form_class = ProjectFormA
    ...
    def get_form_kwargs(self, **kwargs):
        kwargs = super(UpdateViewA, self).get_form_kwargs(**kwargs)
        if self.get_object().kickoff_date == None:
            kwargs['initial']['kickoff_date'] = datetime.date.today()
        return kwargs

class UpdateViewB(UpdateView):
    model = Project
    form_class = ProjectFormB
    ...

class ProjectFormA(ModelForm):
    ...
    class Meta:
        model = Project

class ProjectFormB(ModelForm):
    ...
    class Meta:
        model = Project
}}}

"	Bug	closed	Generic views	1.3	Normal	fixed	model form, generic view	hanson2010@…	Ready for checkin	1	0	0	0	0	0
