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}
)
评论列表
文章目录