product get slug

This commit is contained in:
Parsa Nazer
2025-05-21 15:02:02 +03:30
parent 2874798c67
commit bc214a2bdc
+2 -2
View File
@@ -55,8 +55,8 @@ class ProductView(APIView):
serializer_class = DynamicProductSerializer serializer_class = DynamicProductSerializer
permission_classes = [AllowAny] permission_classes = [AllowAny]
# authentication_classes = [] # authentication_classes = []
def get(self, request, pk): def get(self, request, slug):
product = get_object_or_404(ProductModel, id=pk) product = get_object_or_404(ProductModel, slug=slug)
if request.user.is_authenticated: if request.user.is_authenticated:
cart_obj, _ = OrderModel.objects.get_or_create(user=request.user, status='CART') cart_obj, _ = OrderModel.objects.get_or_create(user=request.user, status='CART')
cart_items = cart_obj.items.all() cart_items = cart_obj.items.all()