validations.py 文件源码

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

项目:drf-url-filters 作者: manjitkumar 项目源码 文件源码
def DatetimeWithTZ(msg=None):
    '''
    Checks whether a value is :
        - a valid castable datetime object with timezone.
    '''
    def fn(value):
        try:
            date = parse_datetime(value) or parse_date(value)
            if date is not None:
                return date
            else:
                raise ValueError
        except ValueError:
            raise Invalid('<{0}> is not a valid datetime.'.format(value))
    return fn
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号