from rest_framework import serializers from taggit_serializer.serializers import TagListSerializerField, TaggitSerializer from .models import Note, Notebook class NoteSerializer(TaggitSerializer, serializers.ModelSerializer): tags = TagListSerializerField() class Meta: model = Note fields = ('title', 'body_text', 'body_qjson', 'body_html', 'url', 'notebook', 'tags') class NotebookSerializer(serializers.HyperlinkedModelSerializer): json_absolute_url = serializers.URLField(source='get_absolute_url', read_only=True) class Meta: model = Notebook fields = ('name', 'json_absolute_url')