2023-02-24 00:13:44 +08:00
|
|
|
from rest_framework import serializers
|
|
|
|
from .models import Note
|
|
|
|
|
|
|
|
|
|
|
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
2023-03-01 23:27:46 +08:00
|
|
|
owner = serializers.ReadOnlyField(source='owner.username')
|
2023-03-04 19:25:40 +08:00
|
|
|
date_created = serializers.DateTimeField(
|
|
|
|
format="%d-%m-%Y %I:%M%p", read_only=True)
|
2023-03-01 23:27:46 +08:00
|
|
|
|
2023-02-24 00:13:44 +08:00
|
|
|
class Meta:
|
|
|
|
model = Note
|
2023-03-29 19:37:42 +08:00
|
|
|
fields = ('id', 'title', 'content', 'date_created', 'owner', 'public')
|
2023-03-04 19:25:40 +08:00
|
|
|
read_only_fields = ('id', 'date_created', 'owner')
|