diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
index 3cade52..d107e9a 100644
|
a
|
b
|
class FormMixin(object):
|
| 19 | 19 | """ |
| 20 | 20 | Returns the initial data to use for forms on this view. |
| 21 | 21 | """ |
| 22 | | return self.initial |
| | 22 | return self.initial.copy() |
| 23 | 23 | |
| 24 | 24 | def get_form_class(self): |
| 25 | 25 | """ |
diff --git a/docs/ref/class-based-views.txt b/docs/ref/class-based-views.txt
index e1ff289..5223aee 100644
|
a
|
b
|
FormMixin
|
| 431 | 431 | |
| 432 | 432 | .. method:: get_initial() |
| 433 | 433 | |
| 434 | | Retrieve initial data for the form. By default, returns |
| | 434 | Retrieve initial data for the form. By default, returns a copy of |
| 435 | 435 | :attr:`.initial`. |
| 436 | 436 | |
| | 437 | .. admonition:: Changed in 1.4 |
| | 438 | |
| | 439 | In Django 1.3, this method was returning the :attr:`initial` class |
| | 440 | variable itself. |
| | 441 | |
| 437 | 442 | .. method:: get_form_class() |
| 438 | 443 | |
| 439 | 444 | Retrieve the form class to instantiate. By default |
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
index d82ca03..211d136 100644
|
a
|
b
|
passed to the markdown filter, both the ``safe_mode=True`` and
|
| 1107 | 1107 | Python-Markdown library less than 2.1, a warning is issued that the output is |
| 1108 | 1108 | insecure. |
| 1109 | 1109 | |
| | 1110 | FormMixin get_initial returns an instance-specific dictionary |
| | 1111 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | 1112 | |
| | 1113 | In Django 1.3, the ``get_initial`` method of the |
| | 1114 | :class:`django.views.generic.edit.FormMixin` class was returning the |
| | 1115 | class ``initial`` dictionary. This has been fixed to return a copy of this |
| | 1116 | dictionary, so form instances can modify their initial data without messing |
| | 1117 | with the class variable. |
| | 1118 | |
| 1110 | 1119 | Features deprecated in 1.4 |
| 1111 | 1120 | ========================== |
| 1112 | 1121 | |
diff --git a/tests/regressiontests/generic_views/edit.py b/tests/regressiontests/generic_views/edit.py
index 2bd982e..651e14f 100644
|
a
|
b
|
from django.core.urlresolvers import reverse
|
| 5 | 5 | from django import forms |
| 6 | 6 | from django.test import TestCase |
| 7 | 7 | from django.utils.unittest import expectedFailure |
| | 8 | from django.views.generic.edit import FormMixin |
| 8 | 9 | |
| 9 | 10 | from . import views |
| 10 | 11 | from .models import Artist, Author |
| 11 | 12 | |
| 12 | 13 | |
| | 14 | class FormMixinTests(TestCase): |
| | 15 | def test_initial_data(self): |
| | 16 | """ Test instance independence of initial data dict (see #16138) """ |
| | 17 | initial_1 = FormMixin().get_initial() |
| | 18 | initial_1['foo'] = 'bar' |
| | 19 | initial_2 = FormMixin().get_initial() |
| | 20 | self.assertNotEqual(initial_1, initial_2) |
| | 21 | |
| 13 | 22 | class ModelFormMixinTests(TestCase): |
| 14 | 23 | def test_get_form(self): |
| 15 | 24 | form_class = views.AuthorGetQuerySetFormView().get_form_class() |
diff --git a/tests/regressiontests/generic_views/tests.py b/tests/regressiontests/generic_views/tests.py
index d387216..72aab03 100644
|
a
|
b
|
from .dates import (ArchiveIndexViewTests, YearArchiveViewTests,
|
| 5 | 5 | MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, |
| 6 | 6 | DateDetailViewTests) |
| 7 | 7 | from .detail import DetailViewTest |
| 8 | | from .edit import (ModelFormMixinTests, CreateViewTests, UpdateViewTests, |
| 9 | | DeleteViewTests) |
| | 8 | from .edit import (FormMixinTests, ModelFormMixinTests, CreateViewTests, |
| | 9 | UpdateViewTests, DeleteViewTests) |
| 10 | 10 | from .list import ListViewTests |