From c486b12f33295f2d56e9836dc379adf986f87c91 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Mon, 6 Mar 2023 15:38:47 +0800 Subject: [PATCH] Add id in serializer --- ivy/products/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ivy/products/serializers.py b/ivy/products/serializers.py index 321221e..85d5dc3 100644 --- a/ivy/products/serializers.py +++ b/ivy/products/serializers.py @@ -5,8 +5,9 @@ from .models import Product class ProductSerializer(serializers.HyperlinkedModelSerializer): date_added = serializers.DateTimeField( format="%d-%m-%Y %I:%M%p", read_only=True) + quantity = serializers.IntegerField(required=False, default=0) class Meta: model = Product - fields = ('name', 'quantity', 'date_added') + fields = ('id', 'name', 'quantity', 'date_added') read_only_fields = ('id', 'date_added')