1👍
class PostSerializer(serializers.ModelSerializer):
str_timestamp = serializers.SerializerMethodField(
method_name="get_str_timestamp"
)
class Meta:
model = Post
fields = '__all__'
def get_str_timestamp(self, obj: Post):
return obj.timestamp.strftime('%b %d %Y, %I:%M %p')
Source:stackexchange.com