fix: created product update serializer
This commit is contained in:
@@ -21,7 +21,7 @@ from shop.api.v1.serializers import (
|
||||
CreateProductSerializer,
|
||||
CreateProductPriceSerializer,
|
||||
TagSerializer,
|
||||
ListProductSerializer,
|
||||
ListProductSerializer, UpdateProductSerializer,
|
||||
)
|
||||
from shop.models import (
|
||||
Product,
|
||||
@@ -40,7 +40,7 @@ from shop.api.v1.permissions import ProductPermissions, ProductPricePermissions
|
||||
|
||||
class ProductViewSet(ModelViewSet):
|
||||
serializer_class = ProductSerializer
|
||||
queryset = Product.objects.prefetch_related("prices").all()
|
||||
queryset = Product.objects.prefetch_related("prices").prefetch_related("tags").prefetch_related("images").all()
|
||||
permission_classes = (
|
||||
IsAdminUser,
|
||||
ProductPermissions,
|
||||
@@ -52,6 +52,8 @@ class ProductViewSet(ModelViewSet):
|
||||
return CreateProductSerializer
|
||||
elif self.action == "list":
|
||||
return ListProductSerializer
|
||||
elif self.action in ('update', 'partial_update'):
|
||||
return UpdateProductSerializer
|
||||
return self.serializer_class
|
||||
|
||||
def perform_destroy(self, instance):
|
||||
|
||||
Reference in New Issue
Block a user