models.py 文件源码

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

项目:wagtailmedia 作者: torchbox 项目源码 文件源码
def get_media_model():
    from django.conf import settings
    from django.apps import apps

    try:
        app_label, model_name = settings.WAGTAILMEDIA_MEDIA_MODEL.split('.')
    except AttributeError:
        return Media
    except ValueError:
        raise ImproperlyConfigured("WAGTAILMEDIA_MEDIA_MODEL must be of the form 'app_label.model_name'")

    media_model = apps.get_model(app_label, model_name)
    if media_model is None:
        raise ImproperlyConfigured(
            "WAGTAILMEDIA_MEDIA_MODEL refers to model '%s' that has not been installed" %
            settings.WAGTAILMEDIA_MEDIA_MODEL
        )
    return media_model


# Receive the pre_delete signal and delete the file associated with the model instance.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号