from rest_framework import serializers
from post.models import Post


class PostSerializer(serializers.ModelSerializer):
    username = serializers.SerializerMethodField()
    topicname = serializers.SerializerMethodField()


    class Meta:
        model = Post
        fields = ('id', 'image', 'video', 'date', 'description', 'order',
            'topic', 'user', 'victories', 'username', 'topicname')

    def get_username(self, obj):
        return obj.user.username

    def get_topicname(self, obj):
        return obj.topic.name

6ca426f7d2b5da7a23416cc1a2079cdfee09c4d6
<mask token>


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


    class Meta:
        model = Post
        fields = ('id', 'image', 'video', 'date', 'description', 'order',
            'topic', 'user', 'victories', 'username', 'topicname')

    def get_username(self, obj):
        return obj.user.username
    <mask token>

<mask token>


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


    class Meta:
        model = Post
        fields = ('id', 'image', 'video', 'date', 'description', 'order',
            'topic', 'user', 'victories', 'username', 'topicname')

    def get_username(self, obj):
        return obj.user.username

    def get_topicname(self, obj):
        return obj.topic.name

<mask token>


class PostSerializer(serializers.ModelSerializer):
    username = serializers.SerializerMethodField()
    topicname = serializers.SerializerMethodField()


    class Meta:
        model = Post
        fields = ('id', 'image', 'video', 'date', 'description', 'order',
            'topic', 'user', 'victories', 'username', 'topicname')

    def get_username(self, obj):
        return obj.user.username

    def get_topicname(self, obj):
        return obj.topic.name

from rest_framework import serializers
from post.models import Post


class PostSerializer(serializers.ModelSerializer):
    username = serializers.SerializerMethodField()
    topicname = serializers.SerializerMethodField()


    class Meta:
        model = Post
        fields = ('id', 'image', 'video', 'date', 'description', 'order',
            'topic', 'user', 'victories', 'username', 'topicname')

    def get_username(self, obj):
        return obj.user.username

    def get_topicname(self, obj):
        return obj.topic.name
