python类Model()的实例源码

models.py 文件源码 项目:imagery 作者: cenima-ibama 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def validate_scene_name(value):
    """Validator for the scene_name field of PastSceneDownload Model."""
    try:
        Scene.objects.get(name=value)
        raise ValidationError(
            _('The scene you want is already on our database.')
            )
    except Scene.DoesNotExist:
        if len(value) != 21:
            raise ValidationError(
                _('The scene name needs to have 21 characters.')
            )
        elif not value.startswith('L') or value[2] not in ['5', '7', '8']:
            raise ValidationError(
                _('Wrong scene name. Please check it.')
            )
models.py 文件源码 项目:imagery 作者: cenima-ibama 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def post_delete_scene(sender, instance, *args, **kwargs):
    """Overwrites post_delete method of Scene Model to delete also the folder
    fisically in the disk.
    """
    if exists(instance.dir()):
        rmtree(instance.dir())
models.py 文件源码 项目:imagery 作者: cenima-ibama 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def post_delete_image(sender, instance, *args, **kwargs):
    """Overwrites post_delete method of Image Model to delete also the file
    fisically in the disk.
    """
    if instance.file_exists():
        remove(instance.file_path())


问题


面经


文章

微信
公众号

扫码关注公众号