views.py 文件源码

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

项目:longclaw 作者: JamesRamm 项目源码 文件源码
def requests_admin(request, pk):
    """Table display of each request for a given product.

    Allows the given Page pk to refer to a direct parent of
    the ProductVariant model or be the ProductVariant model itself.
    This allows for the standard longclaw product modelling philosophy where
    ProductVariant refers to the actual product (in the case where there is
    only 1 variant) or to be variants of the product page.
    """
    page = Page.objects.get(pk=pk).specific
    if hasattr(page, 'variants'):
        requests = ProductRequest.objects.filter(
            variant__in=page.variants.all()
        )
    else:
        requests = ProductRequest.objects.filter(variant=page)
    return render(
        request,
        "productrequests/requests_admin.html",
        {'page': page, 'requests': requests}
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号