diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py index 474cd8d467..fff72e056c 100644 --- a/django/db/backends/mysql/operations.py +++ b/django/db/backends/mysql/operations.py @@ -219,7 +219,8 @@ class DatabaseOperations(BaseDatabaseOperations): elif internal_type in ['BooleanField', 'NullBooleanField']: converters.append(self.convert_booleanfield_value) elif internal_type == 'DateTimeField': - converters.append(self.convert_datetimefield_value) + if settings.USE_TZ: + converters.append(self.convert_datetimefield_value) elif internal_type == 'UUIDField': converters.append(self.convert_uuidfield_value) return converters @@ -236,8 +237,7 @@ class DatabaseOperations(BaseDatabaseOperations): def convert_datetimefield_value(self, value, expression, connection): if value is not None: - if settings.USE_TZ: - value = timezone.make_aware(value, self.connection.timezone) + value = timezone.make_aware(value, self.connection.timezone) return value def convert_uuidfield_value(self, value, expression, connection): diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py index fa29a8925a..fd4206d57f 100644 --- a/django/db/backends/oracle/operations.py +++ b/django/db/backends/oracle/operations.py @@ -153,7 +153,8 @@ END; elif internal_type in ['BooleanField', 'NullBooleanField']: converters.append(self.convert_booleanfield_value) elif internal_type == 'DateTimeField': - converters.append(self.convert_datetimefield_value) + if settings.USE_TZ: + converters.append(self.convert_datetimefield_value) elif internal_type == 'DateField': converters.append(self.convert_datefield_value) elif internal_type == 'TimeField': @@ -192,8 +193,7 @@ END; def convert_datetimefield_value(self, value, expression, connection): if value is not None: - if settings.USE_TZ: - value = timezone.make_aware(value, self.connection.timezone) + value = timezone.make_aware(value, self.connection.timezone) return value def convert_datefield_value(self, value, expression, connection):