Ticket #16138: 16138-4.diff

File 16138-4.diff, 3.5 KB (added by Claude Paroz, 13 years ago)

Consolidate fix/test/docs patches

  • django/views/generic/edit.py

    diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
    index 3cade52..d107e9a 100644
    a b class FormMixin(object):  
    1919        """
    2020        Returns the initial data to use for forms on this view.
    2121        """
    22         return self.initial
     22        return self.initial.copy()
    2323
    2424    def get_form_class(self):
    2525        """
  • docs/ref/class-based-views.txt

    diff --git a/docs/ref/class-based-views.txt b/docs/ref/class-based-views.txt
    index e1ff289..5223aee 100644
    a b FormMixin  
    431431
    432432    .. method:: get_initial()
    433433
    434         Retrieve initial data for the form. By default, returns
     434        Retrieve initial data for the form. By default, returns a copy of
    435435        :attr:`.initial`.
    436436
     437    .. admonition:: Changed in 1.4
     438
     439        In Django 1.3, this method was returning the :attr:`initial` class
     440        variable itself.
     441
    437442    .. method:: get_form_class()
    438443
    439444        Retrieve the form class to instantiate. By default
  • docs/releases/1.4.txt

    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  
    11071107Python-Markdown library less than 2.1, a warning is issued that the output is
    11081108insecure.
    11091109
     1110FormMixin get_initial returns an instance-specific dictionary
     1111~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1112
     1113In Django 1.3, the ``get_initial`` method of the
     1114:class:`django.views.generic.edit.FormMixin` class was returning the
     1115class ``initial`` dictionary. This has been fixed to return a copy of this
     1116dictionary, so form instances can modify their initial data without messing
     1117with the class variable.
     1118
    11101119Features deprecated in 1.4
    11111120==========================
    11121121
  • tests/regressiontests/generic_views/edit.py

    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  
    55from django import forms
    66from django.test import TestCase
    77from django.utils.unittest import expectedFailure
     8from django.views.generic.edit import FormMixin
    89
    910from . import views
    1011from .models import Artist, Author
    1112
    1213
     14class 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
    1322class ModelFormMixinTests(TestCase):
    1423    def test_get_form(self):
    1524        form_class = views.AuthorGetQuerySetFormView().get_form_class()
  • tests/regressiontests/generic_views/tests.py

    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,  
    55    MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests,
    66    DateDetailViewTests)
    77from .detail import DetailViewTest
    8 from .edit import (ModelFormMixinTests, CreateViewTests, UpdateViewTests,
    9     DeleteViewTests)
     8from .edit import (FormMixinTests, ModelFormMixinTests, CreateViewTests,
     9    UpdateViewTests, DeleteViewTests)
    1010from .list import ListViewTests
Back to Top