Ticket #17742: 17742.patch

File 17742.patch, 780 bytes (added by Aymeric Augustin, 13 years ago)
  • django/db/models/fields/__init__.py

    diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
    index 3e97f6c..79fb373 100644
    a b class DateField(Field):  
    667667        if value is None:
    668668            return value
    669669        if isinstance(value, datetime.datetime):
     670            if settings.USE_TZ and timezone.is_aware(value):
     671                # Convert aware datetimes to the current time zone
     672                # before casting them to dates (#17742).
     673                default_timezone = timezone.get_default_timezone()
     674                value = timezone.make_naive(value, default_timezone)
    670675            return value.date()
    671676        if isinstance(value, datetime.date):
    672677            return value
Back to Top