validators.py 文件源码

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

项目:Plamber 作者: OlegKlimenko 项目源码 文件源码
def validate_pdf(value):
    """
    Validates the uploading file if it is a PDF.
    Raises an error if validation not passed.

    :param value: The file object.
    """
    try:
        PyPDF2.PdfFileReader(io.BytesIO(value.read()))
    except PyPDF2.utils.PdfReadError:
        raise ValidationError('Tried to upload not PDF as a book!')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号