shortcuts.py 文件源码

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

项目:django-wechat-api 作者: crazy-canux 项目源码 文件源码
def get_object_or_404(klass, *args, **kwargs):
    """
    Uses get() to return an object, or raises a Http404 exception if the object
    does not exist.

    klass may be a Model, Manager, or QuerySet object. All other passed
    arguments and keyword arguments are used in the get() query.

    Note: Like with get(), an MultipleObjectsReturned will be raised if more than one
    object is found.
    """
    queryset = _get_queryset(klass)
    try:
        return queryset.get(*args, **kwargs)
    except queryset.model.DoesNotExist:
        raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号