Created
July 9, 2014 17:34
-
-
Save maryokhin/43f0c951bbea943b95b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostSerializer(ModelSerializer): | |
""" | |
General post serializer. | |
""" | |
url = ReverseField(view_name='post-instance') | |
channel = ChannelSerializer(read_only=True) | |
user = UserInstanceSerializer(read_only=True) | |
latest_comments = serializers.SerializerMethodField('get_latest_comments') | |
comments_url = ReverseField(view_name='post-comment-list') | |
channel_id = serializers.PrimaryKeyRelatedField(source='channel', write_only=True) | |
user_id = serializers.PrimaryKeyRelatedField(source='user', write_only=True) | |
class Meta(): | |
model = Post |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment