diff --git a/django/contrib/formtools/utils.py b/django/contrib/formtools/utils.py
index a357255..d557460 100644
a
|
b
|
def security_hash(request, form, *args):
|
15 | 15 | order, pickles the result with the SECRET_KEY setting, then takes an md5 |
16 | 16 | hash of that. |
17 | 17 | """ |
18 | | |
19 | | data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] |
| 18 | if form.empty_permitted and not form.has_changed(): |
| 19 | data = [(bf.name, bf.data or '') for bf in form] |
| 20 | else: |
| 21 | data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] |
20 | 22 | data.extend(args) |
21 | 23 | data.append(settings.SECRET_KEY) |
22 | 24 | |
diff --git a/tests/regressiontests/forms/formtools.py b/tests/regressiontests/forms/formtools.py
new file mode 100644
index 0000000..e631b25
-
|
+
|
|
| 1 | # -*- coding: utf-8 -*- |
| 2 | from django.test import TestCase |
| 3 | from django import forms |
| 4 | |
| 5 | __all__ = ('FormToolsUtilsTests', ) |
| 6 | |
| 7 | class BlankForm(forms.Form): |
| 8 | name = forms.CharField(max_length=10, required=False) |
| 9 | class NotBlankForm(forms.Form): |
| 10 | name = forms.CharField(max_length=10) |
| 11 | |
| 12 | class FormToolsUtilsTests(TestCase): |
| 13 | def test_security_hash_empty_permitted_form(self): |
| 14 | """Check that formtools.utils.security_hash handles forms with |
| 15 | empty_permitted=True""" |
| 16 | blank_form = BlankForm({}) |
| 17 | not_blank_form = NotBlankForm({}, empty_permitted=True) |
| 18 | |
| 19 | from django.contrib.formtools.utils import security_hash |
| 20 | self.assertEqual(security_hash(None, blank_form), security_hash(None, not_blank_form)) |
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py
index 6d418fa..d931663 100644
a
|
b
|
from widgets import tests as widgets_tests
|
32 | 32 | from formsets import tests as formset_tests |
33 | 33 | from media import media_tests |
34 | 34 | |
| 35 | from regressiontests.forms.formtools import * |
| 36 | |
35 | 37 | __test__ = { |
36 | 38 | 'extra_tests': extra_tests, |
37 | 39 | 'fields_tests': fields_tests, |