(self, value)
| 1699 | # get_next_by_FOO and get_prev_by_FOO |
| 1700 | |
| 1701 | def get_prep_value(self, value): |
| 1702 | value = super().get_prep_value(value) |
| 1703 | value = self.to_python(value) |
| 1704 | if value is not None and settings.USE_TZ and timezone.is_naive(value): |
| 1705 | # For backwards compatibility, interpret naive datetimes in local |
| 1706 | # time. This won't work during DST change, but we can't do much |
| 1707 | # about it, so we let the exceptions percolate up the call stack. |
| 1708 | try: |
| 1709 | name = "%s.%s" % (self.model.__name__, self.name) |
| 1710 | except AttributeError: |
| 1711 | name = "(unbound)" |
| 1712 | warnings.warn( |
| 1713 | "DateTimeField %s received a naive datetime (%s)" |
| 1714 | " while time zone support is active." % (name, value), |
| 1715 | RuntimeWarning, |
| 1716 | ) |
| 1717 | default_timezone = timezone.get_default_timezone() |
| 1718 | value = timezone.make_aware(value, default_timezone) |
| 1719 | return value |
| 1720 | |
| 1721 | def get_db_prep_value(self, value, connection, prepared=False): |
| 1722 | # Casts datetimes into the format expected by the backend |
no test coverage detected