Ticket #17294: 17294.patch
File 17294.patch, 2.4 KB (added by , 13 years ago) |
---|
-
tests/modeltests/timezones/tests.py
25 25 from django.utils.unittest import skipIf 26 26 27 27 from .forms import EventForm, EventSplitForm, EventModelForm 28 from .models import Event, Timestamp28 from .models import Event, MaybeEvent, Timestamp 29 29 30 30 31 31 # These tests use the EAT (Eastern Africa Time) and ICT (Indochina Time) … … 403 403 datetime.datetime(2011, 1, 1, tzinfo=UTC)], 404 404 transform=lambda d: d) 405 405 406 def test_null_datetime(self): 407 # Regression for #17294 408 e = MaybeEvent.objects.create() 409 self.assertEqual(e.dt, None) 410 406 411 NewDatabaseTests = override_settings(USE_TZ=True)(NewDatabaseTests) 407 412 408 413 -
tests/modeltests/timezones/models.py
3 3 class Event(models.Model): 4 4 dt = models.DateTimeField() 5 5 6 class MaybeEvent(models.Model): 7 dt = models.DateTimeField(blank=True, null=True) 8 6 9 class Timestamp(models.Model): 7 10 created = models.DateTimeField(auto_now_add=True) 8 11 updated = models.DateTimeField(auto_now=True) -
tests/modeltests/timezones/forms.py
1 1 from django import forms 2 2 3 from .models import Event 3 from .models import Event, MaybeEvent 4 4 5 5 class EventForm(forms.Form): 6 6 dt = forms.DateTimeField() -
django/db/models/fields/__init__.py
786 786 787 787 def get_prep_value(self, value): 788 788 value = self.to_python(value) 789 if settings.USE_TZ and timezone.is_naive(value):789 if value is not None and settings.USE_TZ and timezone.is_naive(value): 790 790 # For backwards compatibility, interpret naive datetimes in local 791 791 # time. This won't work during DST change, but we can't do much 792 792 # about it, so we let the exceptions percolate up the call stack.