summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNasir Hussain <nasirhjafri@gmail.com>2019-09-16 22:29:13 +0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-17 12:21:02 +0200
commit685d956764e6c76d1834274f3afa6ef0ce5d85a1 (patch)
treee559eefb66717b7bc7a61dcd64990fa6c2517881 /tests
parent14125bb039a835a6297c0abd1ee4f4a9ad062f84 (diff)
[3.0.x] Fixed #30758 -- Made RangeFields use multiple hidden inputs for initial data.
Backport of faf4b988fe75dd4045bc5c62496cc4f2e0db8c4d from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/postgres_tests/test_ranges.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py
index 89f32ee77c..74f1ec0ff8 100644
--- a/tests/postgres_tests/test_ranges.py
+++ b/tests/postgres_tests/test_ranges.py
@@ -5,6 +5,7 @@ from decimal import Decimal
from django import forms
from django.core import exceptions, serializers
from django.db.models import DateField, DateTimeField, F, Func, Value
+from django.http import QueryDict
from django.test import ignore_warnings, override_settings
from django.utils import timezone
from django.utils.deprecation import RemovedInDjango31Warning
@@ -512,6 +513,24 @@ class TestFormField(PostgreSQLSimpleTestCase):
value = field.clean(['', ''])
self.assertIsNone(value)
+ def test_datetime_form_initial_data(self):
+ class DateTimeRangeForm(forms.Form):
+ datetime_field = pg_forms.DateTimeRangeField(show_hidden_initial=True)
+
+ data = QueryDict(mutable=True)
+ data.update({
+ 'datetime_field_0': '2010-01-01 11:13:00',
+ 'datetime_field_1': '',
+ 'initial-datetime_field_0': '2010-01-01 10:12:00',
+ 'initial-datetime_field_1': '',
+ })
+ form = DateTimeRangeForm(data=data)
+ self.assertTrue(form.has_changed())
+
+ data['initial-datetime_field_0'] = '2010-01-01 11:13:00'
+ form = DateTimeRangeForm(data=data)
+ self.assertFalse(form.has_changed())
+
def test_rendering(self):
class RangeForm(forms.Form):
ints = pg_forms.IntegerRangeField()