views.py 文件源码

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

项目:shuup-wishlist 作者: shuup 项目源码 文件源码
def form_valid(self, form):
        shop = self.request.shop
        customer = self.request.customer
        product_id = self.request.POST.get('product_id')
        response = {}
        wishlist, created = Wishlist.objects.get_or_create(shop=shop, customer=customer, **form.cleaned_data)
        response['id'] = wishlist.id
        response['name'] = wishlist.name
        if created and product_id:
            wishlist.products.add(product_id)
            response["product_id"] = product_id
            response['product_name'] = wishlist.products.get(pk=product_id).name
        response['created'] = created
        return JsonResponse(response)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号