Python django.contrib.gis.db.models 模块,Model() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用django.contrib.gis.db.models.Model()

项目:imagery    作者:cenima-ibama    | 项目源码 | 文件源码
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.')
            )
项目:imagery    作者:cenima-ibama    | 项目源码 | 文件源码
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())
项目:imagery    作者:cenima-ibama    | 项目源码 | 文件源码
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())