mirror of
https://github.com/lemeow125/Django-NotesApp.git
synced 2024-11-17 14:39:25 +08:00
13 lines
477 B
Python
13 lines
477 B
Python
from rest_framework import serializers
|
|
from .models import Note
|
|
|
|
|
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
|
owner = serializers.ReadOnlyField(source='owner.username')
|
|
date_created = serializers.DateTimeField(
|
|
format="%d-%m-%Y %I:%M%p", read_only=True)
|
|
|
|
class Meta:
|
|
model = Note
|
|
fields = ('id', 'title', 'content', 'date_created', 'owner', 'public')
|
|
read_only_fields = ('id', 'date_created', 'owner')
|