def post(self, request, *args, **kwargs):
print('\n post', request.POST)
product_id = int(request.POST.get('product_id'))
owned_products_id = owned_products_pk(request.user)
print('product_id owned?', product_id, owned_products_id,product_id in owned_products_id, type(product_id), type(owned_products_id[0]) )
if product_id in owned_products_id:
product = Product.objects.get(id=product_id)
response = HttpResponse()
url = "/books/virtual_store/{}",format(product.file.name)
print('redirect to url', url)
response['X-Accel-Redirect'] = url
return response
return HttpResponseRedirect(reverse('customer:personal-library'))
messages.info(
self.request,
"Product not owned")
评论列表
文章目录