summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2010-11-21 17:27:01 +0000
committerHonza Král <honza.kral@gmail.com>2010-11-21 17:27:01 +0000
commit65b380e74ab79ee011f7556e342dd4d656b018a5 (patch)
treebbab2ce8c6ab22c9648d3f2bc1d1b1264f2ad8fc /docs
parent752bd8bf75f1bf64e5014ee65b65b173197e5f53 (diff)
Fixed #11418 -- formset.cleaned_data no longer raises AttributeError when is_valid is True. Thanks mlavin!
This also introduces a slightly backwards-incompatible change in FormSet's behavior, see the release docs for details. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14667 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.3.txt30
-rw-r--r--docs/topics/forms/formsets.txt13
2 files changed, 39 insertions, 4 deletions
diff --git a/docs/releases/1.3.txt b/docs/releases/1.3.txt
index d1c42496ce..24702111a2 100644
--- a/docs/releases/1.3.txt
+++ b/docs/releases/1.3.txt
@@ -266,6 +266,36 @@ local flavors:
has been removed from the province list in favor of the new
official designation "Aceh (ACE)".
+FormSet updates
+~~~~~~~~~~~~~~~
+
+In Django 1.3 ``FormSet`` creation behavior is modified slightly. Historically
+the class didn't make a distinction between not being passed data and being
+passed empty dictionary. This was inconsistent with behavior in other parts of
+the framework. Starting with 1.3 if you pass in empty dictionary the
+``FormSet`` will raise a ``ValidationError``.
+
+For example with a ``FormSet``::
+
+ >>> class ArticleForm(Form):
+ ... title = CharField()
+ ... pub_date = DateField()
+ >>> ArticleFormSet = formset_factory(ArticleForm)
+
+the following code will raise a ``ValidationError``::
+
+ >>> ArticleFormSet({})
+ Traceback (most recent call last):
+ ...
+ ValidationError: [u'ManagementForm data is missing or has been tampered with']
+
+if you need to instantiate an empty ``FormSet``, don't pass in the data or use
+``None``::
+
+ >>> formset = ArticleFormSet()
+ >>> formset = ArticleFormSet(data=None)
+
+
.. _deprecated-features-1.3:
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt
index e7b09dc409..fae76c7a2e 100644
--- a/docs/topics/forms/formsets.txt
+++ b/docs/topics/forms/formsets.txt
@@ -100,7 +100,12 @@ an ``is_valid`` method on the formset to provide a convenient way to validate
all forms in the formset::
>>> ArticleFormSet = formset_factory(ArticleForm)
- >>> formset = ArticleFormSet({})
+ >>> data = {
+ ... 'form-TOTAL_FORMS': u'1',
+ ... 'form-INITIAL_FORMS': u'0',
+ ... 'form-MAX_NUM_FORMS': u'',
+ ... }
+ >>> formset = ArticleFormSet(data)
>>> formset.is_valid()
True
@@ -113,7 +118,7 @@ provide an invalid article::
... 'form-INITIAL_FORMS': u'0',
... 'form-MAX_NUM_FORMS': u'',
... 'form-0-title': u'Test',
- ... 'form-0-pub_date': u'16 June 1904',
+ ... 'form-0-pub_date': u'1904-06-16',
... 'form-1-title': u'Test',
... 'form-1-pub_date': u'', # <-- this date is missing but required
... }
@@ -208,9 +213,9 @@ is where you define your own validation that works at the formset level::
... 'form-INITIAL_FORMS': u'0',
... 'form-MAX_NUM_FORMS': u'',
... 'form-0-title': u'Test',
- ... 'form-0-pub_date': u'16 June 1904',
+ ... 'form-0-pub_date': u'1904-06-16',
... 'form-1-title': u'Test',
- ... 'form-1-pub_date': u'23 June 1912',
+ ... 'form-1-pub_date': u'1912-06-23',
... }
>>> formset = ArticleFormSet(data)
>>> formset.is_valid()