mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #17294 -- Supported nullable DateTimeFields when time zone support is enabled. Thanks pressureman for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17148 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e954a03871
commit
866c229f52
4 changed files with 13 additions and 2 deletions
|
|
@ -3,6 +3,9 @@ from django.db import models
|
|||
class Event(models.Model):
|
||||
dt = models.DateTimeField()
|
||||
|
||||
class MaybeEvent(models.Model):
|
||||
dt = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
class Timestamp(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from django.utils.tzinfo import FixedOffset
|
|||
from django.utils.unittest import skipIf
|
||||
|
||||
from .forms import EventForm, EventSplitForm, EventModelForm
|
||||
from .models import Event, Timestamp
|
||||
from .models import Event, MaybeEvent, Timestamp
|
||||
|
||||
|
||||
# These tests use the EAT (Eastern Africa Time) and ICT (Indochina Time)
|
||||
|
|
@ -403,6 +403,11 @@ class NewDatabaseTests(BaseDateTimeTests):
|
|||
datetime.datetime(2011, 1, 1, tzinfo=UTC)],
|
||||
transform=lambda d: d)
|
||||
|
||||
def test_null_datetime(self):
|
||||
# Regression for #17294
|
||||
e = MaybeEvent.objects.create()
|
||||
self.assertEqual(e.dt, None)
|
||||
|
||||
NewDatabaseTests = override_settings(USE_TZ=True)(NewDatabaseTests)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue