summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2011-11-25 09:25:43 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2011-11-25 09:25:43 +0000
commit866c229f52df29f6b7b07463548532aae421fe42 (patch)
treef5de4cec5cc22e9468f7e0ae3dd1d3897e1363b3 /django
parente954a03871cdc1c155ba7a3f3000dcf75998d9f4 (diff)
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
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/__init__.py2
-rw-r--r--django/utils/timezone.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 6824ba17f2..04b13aa5c8 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -786,7 +786,7 @@ class DateTimeField(DateField):
def get_prep_value(self, value):
value = self.to_python(value)
- if settings.USE_TZ and timezone.is_naive(value):
+ if value is not None and settings.USE_TZ and timezone.is_naive(value):
# For backwards compatibility, interpret naive datetimes in local
# time. This won't work during DST change, but we can't do much
# about it, so we let the exceptions percolate up the call stack.
diff --git a/django/utils/timezone.py b/django/utils/timezone.py
index 16e65fc62d..0476d46f7e 100644
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -228,6 +228,9 @@ def now():
else:
return datetime.now()
+# By design, these four functions don't perform any checks on their arguments.
+# The caller should ensure that they don't receive an invalid value like None.
+
def is_aware(value):
"""
Determines if a given datetime.datetime is aware.