from rest_framework import serializers
from core.models import Post, User, Comment


class UserSerialzer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('username',)


class PostSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field="username", read_only=True)

    class Meta:
        model = Post
        lookup_field = 'pk'
        fields = ('user', 'date_created', 'title', 'body',)


class CommentSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field="username", read_only=True)
    post = serializers.SlugRelatedField(slug_field="title", read_only=True)

    class Meta:
        model = Comment
        fields = ('user', 'body', 'post')

51d57af79e0a79bc86bcb83583bc9fd246b73500
<mask token>


class PostSerializer(serializers.ModelSerializer):
    <mask token>


    class Meta:
        model = Post
        lookup_field = 'pk'
        fields = 'user', 'date_created', 'title', 'body'


class CommentSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field='username', read_only=True)
    post = serializers.SlugRelatedField(slug_field='title', read_only=True)


    class Meta:
        model = Comment
        fields = 'user', 'body', 'post'

<mask token>


class PostSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field='username', read_only=True)


    class Meta:
        model = Post
        lookup_field = 'pk'
        fields = 'user', 'date_created', 'title', 'body'


class CommentSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field='username', read_only=True)
    post = serializers.SlugRelatedField(slug_field='title', read_only=True)


    class Meta:
        model = Comment
        fields = 'user', 'body', 'post'

<mask token>


class UserSerialzer(serializers.ModelSerializer):


    class Meta:
        model = User
        fields = 'username',


class PostSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field='username', read_only=True)


    class Meta:
        model = Post
        lookup_field = 'pk'
        fields = 'user', 'date_created', 'title', 'body'


class CommentSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field='username', read_only=True)
    post = serializers.SlugRelatedField(slug_field='title', read_only=True)


    class Meta:
        model = Comment
        fields = 'user', 'body', 'post'

from rest_framework import serializers
from core.models import Post, User, Comment


class UserSerialzer(serializers.ModelSerializer):


    class Meta:
        model = User
        fields = 'username',


class PostSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field='username', read_only=True)


    class Meta:
        model = Post
        lookup_field = 'pk'
        fields = 'user', 'date_created', 'title', 'body'


class CommentSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field='username', read_only=True)
    post = serializers.SlugRelatedField(slug_field='title', read_only=True)


    class Meta:
        model = Comment
        fields = 'user', 'body', 'post'

from rest_framework import serializers
from core.models import Post, User, Comment


class UserSerialzer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('username',)


class PostSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field="username", read_only=True)

    class Meta:
        model = Post
        lookup_field = 'pk'
        fields = ('user', 'date_created', 'title', 'body',)


class CommentSerializer(serializers.ModelSerializer):
    user = serializers.SlugRelatedField(slug_field="username", read_only=True)
    post = serializers.SlugRelatedField(slug_field="title", read_only=True)

    class Meta:
        model = Comment
        fields = ('user', 'body', 'post')
