Removed support for SplitDateTimeWidget with DateTimeField per deprecation timeline.

refs #8898
This commit is contained in:
Tim Graham 2015-01-17 18:49:44 -05:00
parent 2c9e95639e
commit 714277cb4c
3 changed files with 2 additions and 40 deletions

View File

@ -501,18 +501,6 @@ class DateTimeField(BaseTemporalField):
if isinstance(value, datetime.date):
result = datetime.datetime(value.year, value.month, value.day)
return from_current_timezone(result)
if isinstance(value, list):
# Input comes from a SplitDateTimeWidget, for example. So, it's two
# components: date and time.
warnings.warn(
'Using SplitDateTimeWidget with DateTimeField is deprecated. '
'Use SplitDateTimeField instead.',
RemovedInDjango19Warning, stacklevel=2)
if len(value) != 2:
raise ValidationError(self.error_messages['invalid'], code='invalid')
if value[0] in self.empty_values and value[1] in self.empty_values:
return None
value = '%s %s' % tuple(value)
result = super(DateTimeField, self).to_python(value)
return from_current_timezone(result)

View File

@ -502,12 +502,6 @@ For each field, we describe the default widget used if you don't specify
See also :ref:`format localization <format-localization>`.
.. deprecated:: 1.7
The ability to use :class:`SplitDateTimeWidget` with ``DateTimeField``
has been deprecated and will be removed in Django 1.9. Use
:class:`SplitDateTimeField` instead.
``DecimalField``
~~~~~~~~~~~~~~~~

View File

@ -9,17 +9,16 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse
from django.forms import (
BooleanField, CheckboxInput, CheckboxSelectMultiple, ChoiceField,
ClearableFileInput, DateInput, DateTimeField, DateTimeInput, FileInput,
ClearableFileInput, DateInput, DateTimeInput, FileInput,
Form, HiddenInput, MultipleHiddenInput, MultiWidget, NullBooleanSelect,
PasswordInput, RadioSelect, Select, SelectMultiple, SplitDateTimeWidget,
Textarea, TextInput, TimeInput,
)
from django.forms.widgets import RadioFieldRenderer
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.safestring import mark_safe, SafeData
from django.utils import six
from django.utils.translation import activate, deactivate, override
from django.test import TestCase, ignore_warnings, override_settings
from django.test import TestCase, override_settings
from django.utils.encoding import python_2_unicode_compatible, force_text
from ..models import Article
@ -1111,25 +1110,6 @@ class WidgetTests(TestCase):
# to make a copy of its sub-widgets when it is copied.
self.assertEqual(w1.choices, [1, 2, 3])
@ignore_warnings(category=RemovedInDjango19Warning)
def test_13390(self):
# See ticket #13390
class SplitDateForm(Form):
field = DateTimeField(widget=SplitDateTimeWidget, required=False)
form = SplitDateForm({'field': ''})
self.assertTrue(form.is_valid())
form = SplitDateForm({'field': ['', '']})
self.assertTrue(form.is_valid())
class SplitDateRequiredForm(Form):
field = DateTimeField(widget=SplitDateTimeWidget, required=True)
form = SplitDateRequiredForm({'field': ''})
self.assertFalse(form.is_valid())
form = SplitDateRequiredForm({'field': ['', '']})
self.assertFalse(form.is_valid())
@override_settings(ROOT_URLCONF='forms_tests.urls')
class LiveWidgetTests(AdminSeleniumWebDriverTestCase):