views.py 文件源码

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

项目:django-oscar-bookstore 作者: paiuolo 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号