Ivy-Backend/ivy/products/serializers.py

14 lines
456 B
Python
Raw Normal View History

2023-03-05 21:56:48 +08:00
from rest_framework import serializers
from .models import Product
class ProductSerializer(serializers.HyperlinkedModelSerializer):
date_added = serializers.DateTimeField(
format="%d-%m-%Y %I:%M%p", read_only=True)
2023-03-06 15:38:47 +08:00
quantity = serializers.IntegerField(required=False, default=0)
2023-03-05 21:56:48 +08:00
class Meta:
model = Product
2023-03-06 15:38:47 +08:00
fields = ('id', 'name', 'quantity', 'date_added')
2023-03-05 21:56:48 +08:00
read_only_fields = ('id', 'date_added')