from rest_framework import serializers
from .models import Comment
from django.contrib.auth.models import User


class OwnerSerializer(serializers.RelatedField):
	def to_representation(self, value):
		return {'id':value.id, 'username': value.username}

class CommentSerializer(serializers.HyperlinkedModelSerializer):
	owner = OwnerSerializer(read_only=True)
	
	class Meta:
		model = Comment
		fields = ('id', 'text', 'owner', 'target')
		read_only_fields = ('target',)
ce6fbc081120f35ed8f7d122bfbf1ef8a9e0d78f
<mask token>


class CommentSerializer(serializers.HyperlinkedModelSerializer):
    owner = OwnerSerializer(read_only=True)


    class Meta:
        model = Comment
        fields = 'id', 'text', 'owner', 'target'
        read_only_fields = 'target',

<mask token>


class OwnerSerializer(serializers.RelatedField):
    <mask token>


class CommentSerializer(serializers.HyperlinkedModelSerializer):
    owner = OwnerSerializer(read_only=True)


    class Meta:
        model = Comment
        fields = 'id', 'text', 'owner', 'target'
        read_only_fields = 'target',

<mask token>


class OwnerSerializer(serializers.RelatedField):

    def to_representation(self, value):
        return {'id': value.id, 'username': value.username}


class CommentSerializer(serializers.HyperlinkedModelSerializer):
    owner = OwnerSerializer(read_only=True)


    class Meta:
        model = Comment
        fields = 'id', 'text', 'owner', 'target'
        read_only_fields = 'target',

from rest_framework import serializers
from .models import Comment
from django.contrib.auth.models import User


class OwnerSerializer(serializers.RelatedField):

    def to_representation(self, value):
        return {'id': value.id, 'username': value.username}


class CommentSerializer(serializers.HyperlinkedModelSerializer):
    owner = OwnerSerializer(read_only=True)


    class Meta:
        model = Comment
        fields = 'id', 'text', 'owner', 'target'
        read_only_fields = 'target',

from rest_framework import serializers
from .models import Comment
from django.contrib.auth.models import User


class OwnerSerializer(serializers.RelatedField):
	def to_representation(self, value):
		return {'id':value.id, 'username': value.username}

class CommentSerializer(serializers.HyperlinkedModelSerializer):
	owner = OwnerSerializer(read_only=True)
	
	class Meta:
		model = Comment
		fields = ('id', 'text', 'owner', 'target')
		read_only_fields = ('target',)