Revised date formatting for serializers.py

This commit is contained in:
keannu125 2023-03-09 23:20:36 +08:00
parent 65a95a90af
commit 72130ca09a

View file

@ -12,7 +12,7 @@ class HistoricalRecordField(serializers.ListField):
class ProductSerializer(serializers.HyperlinkedModelSerializer): class ProductSerializer(serializers.HyperlinkedModelSerializer):
date_added = serializers.DateTimeField( date_added = serializers.DateTimeField(
format="%d-%m-%Y %I:%M%p", read_only=True) format="%m-%d-%Y %I:%M%p", read_only=True)
quantity = serializers.IntegerField(required=False, default=0) quantity = serializers.IntegerField(required=False, default=0)
history = HistoricalRecordField(read_only=True) history = HistoricalRecordField(read_only=True)
@ -24,7 +24,7 @@ class ProductSerializer(serializers.HyperlinkedModelSerializer):
class LogSerializer(serializers.HyperlinkedModelSerializer): class LogSerializer(serializers.HyperlinkedModelSerializer):
history_date = serializers.DateTimeField( history_date = serializers.DateTimeField(
format="%d-%m-%Y %I:%M%p", read_only=True) format="%m-%d-%Y %I:%M%p", read_only=True)
history_user = serializers.ReadOnlyField(source='history_user.username') history_user = serializers.ReadOnlyField(source='history_user.username')
class Meta: class Meta: