summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCurtis Maloney <curtis@tinbrain.net>2015-08-04 10:47:58 +1000
committerMarkus Holtermann <info@markusholtermann.eu>2015-08-04 19:15:22 +1000
commit9f73009e98c51986a50cc45844b8bca72673e955 (patch)
treef6f71e5100f4f26b00979c3dbad3839117f6fb53
parent770449e24b3b0fa60d870bc3404961ddca754c3b (diff)
Fixed #25215 -- Solved reference to forms.HStoreField in declaration of HStoreField
Correct test which was using the model field in a test form.
-rw-r--r--django/contrib/postgres/forms/hstore.py2
-rw-r--r--docs/releases/1.8.4.txt3
-rw-r--r--tests/postgres_tests/test_hstore.py13
3 files changed, 15 insertions, 3 deletions
diff --git a/django/contrib/postgres/forms/hstore.py b/django/contrib/postgres/forms/hstore.py
index a138093e90..3dc70ab2ab 100644
--- a/django/contrib/postgres/forms/hstore.py
+++ b/django/contrib/postgres/forms/hstore.py
@@ -43,4 +43,4 @@ class HStoreField(forms.CharField):
# the same as an empty dict, if the data or initial value we get
# is None, replace it w/ {}.
initial_value = self.to_python(initial)
- return super(forms.HStoreField, self).has_changed(initial_value, data)
+ return super(HStoreField, self).has_changed(initial_value, data)
diff --git a/docs/releases/1.8.4.txt b/docs/releases/1.8.4.txt
index 53c58e6a90..f95bcfb4dc 100644
--- a/docs/releases/1.8.4.txt
+++ b/docs/releases/1.8.4.txt
@@ -21,3 +21,6 @@ Bugfixes
* Prevented an exception in ``TestCase.setUpTestData()`` from leaking the
transaction (:ticket:`25176`).
+
+* Fixed ``has_changed()`` method in
+ :class:`django.contrib.postgres.forms.HStoreField`.
diff --git a/tests/postgres_tests/test_hstore.py b/tests/postgres_tests/test_hstore.py
index 34229bb15c..81ee02dafa 100644
--- a/tests/postgres_tests/test_hstore.py
+++ b/tests/postgres_tests/test_hstore.py
@@ -191,12 +191,21 @@ class TestFormField(PostgreSQLTestCase):
form_field = model_field.formfield()
self.assertIsInstance(form_field, forms.HStoreField)
- def test_empty_field_has_not_changed(self):
+ def test_field_has_changed(self):
class HStoreFormTest(Form):
- f1 = HStoreField()
+ f1 = forms.HStoreField()
form_w_hstore = HStoreFormTest()
self.assertFalse(form_w_hstore.has_changed())
+ form_w_hstore = HStoreFormTest({'f1': '{"a": 1}'})
+ self.assertTrue(form_w_hstore.has_changed())
+
+ form_w_hstore = HStoreFormTest({'f1': '{"a": 1}'}, initial={'f1': '{"a": 1}'})
+ self.assertFalse(form_w_hstore.has_changed())
+
+ form_w_hstore = HStoreFormTest({'f1': '{"a": 2}'}, initial={'f1': '{"a": 1}'})
+ self.assertTrue(form_w_hstore.has_changed())
+
class TestValidator(PostgreSQLTestCase):