class CartDetailAPIView(APIView):
def post(self, request)
if not request.user.get(“status”):
return JsonResponse(request.user, safe=False)
# to test use 4@qq.com
email = request.user.get(“data”).get(“username”)
print(email)
filters = {
“email”: email,
“is_delete”: 0
}
shopping_cart = Cart.objects.filter(**filters).all()
db_data = CartDetailSerializer(shopping_cart, many=True)
return ResponseMessage.CartResponse.success(db_data.data)
这接口本来用
filters = {
“email”: "4@qq.com",
“is_delete”: 0
}
能运行, 改email = request.user.get(“data”).get(“username”)不行啦
前端
onMounted(() => {
getCartDetailData().then(res => {
console.log(res.data);
cartListData.value = res.data;
for(let i in res.data){
cartSumNums.value += res.data[i].nums;
}
})
})
好像没传相关信息.后端哪来的request.user.get(“data”).get(“username”)?