Skip to content

Commit

Permalink
added ProductImageSerializer to ProductSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
knop-k committed Feb 20, 2024
1 parent 4847298 commit a436f74
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Dshop/apps/products_catalogue/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
from django.shortcuts import get_object_or_404
from dj_shop_cart.cart import get_cart_class
from rest_framework import serializers
from .models import Product
from .models import Product, ProductImage


class ProductImageSerializer(serializers.ModelSerializer):
class Meta:
model = ProductImage
fields = ['image']


class ProductSerializer(serializers.ModelSerializer):
images = ProductImageSerializer(many=True, read_only=True)

class Meta:
model = Product
fields = ['id', 'category', 'name', 'price', 'short_description', 'full_description', 'parent_product']
fields = ['id', 'category', 'name', 'price', 'short_description', 'full_description', 'parent_product', 'images']
read_only_fields = ['id']


Expand Down

0 comments on commit a436f74

Please sign in to comment.