operations.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Plamber 作者: OlegKlimenko 项目源码 文件源码
def value_to_db_datetime(self, value):
        if value is None:
            return None
        # MySQL doesn't support tz-aware times
        if timezone.is_aware(value):
            if settings.USE_TZ:
                value = value.astimezone(timezone.utc).replace(tzinfo=None)
            else:
                raise ValueError(
                    "MySQL backend does not support timezone-aware times."
                )
        if not self.connection.features.supports_microsecond_precision:
            value = value.replace(microsecond=0)
        if not self.connection.use_pure:
            return datetime_to_mysql(value)
        return self.connection.converter.to_mysql(value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号