﻿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
17759	FormMixin instantiates form with dict stored on the class	Aron Grififs	nobody	"Consider the following form:

{{{
#!python
class MyForm(ModelForm):
  def __init__(self, *args, **kwargs):
    kwargs['initial']['foo'] = 'bar'
    super(MyForm, self).__init__(*args, **kwargs)
}}}

When used with Django's class-based generic views, this will cause all following form instantiations to have a default `initial` dict with the content `{'foo': 'bar'}` because the dict is inadvertently updated on the class.

The problem is the following code in [source:django/trunk/django/views/generic/edit.py generic/edit.py]:

{{{
#!python
class FormMixin(object):
    initial = {}

    def get_initial(self):
        return self.initial

    def get_form_kwargs(self):
        kwargs = {'initial': self.get_initial()}
        ...
}}}

I think the right fix here is to shallow-copy the dict in get_initial, will attach patch.
"	Bug	closed	Generic views	1.3	Normal	duplicate		aron@… charette.s@…	Accepted	1	0	0	0	0	0
