forms.py 文件源码

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

项目:BioQueue 作者: liyao001 项目源码 文件源码
def clean(self, data, initial=None):
        file = super(RestrictedFileField, self).clean(data, initial)

        try:
            content_type = file.content_type
            if content_type in self.content_types:
                if file._size > self.max_upload_size:
                    raise ValidationError(_('Please keep filesize under %s. Current filesize %s') % (
                        filesizeformat(self.max_upload_size), filesizeformat(file._size)))
            else:
                raise ValidationError(_('Filetype not supported.'))
        except AttributeError:
            pass

        return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号