Commit be56892f authored by Ilya Simonov's avatar Ilya Simonov

add tag and categories to video serializer

parent e298bb4a
from rest_framework import serializers
from .models import Video
from .models import Video, Category, Tag, TagToObject
class TagToObjectSerializer(serializers.ModelSerializer):
id = serializers.CharField(source='tag.id')
name = serializers.CharField(source='tag.name')
class Meta:
model = TagToObject
fields = ['id', 'name']
class CategorySerializer(serializers.ModelSerializer):
class Meta:
model = Category
fields = ['id', 'name']
class VideoSerializer(serializers.ModelSerializer):
categories = CategorySerializer(many=True)
tags = TagToObjectSerializer(many=True)
class Meta:
model = Video
fields = [
......@@ -12,4 +30,6 @@ class VideoSerializer(serializers.ModelSerializer):
'description',
's3_file',
'thumbnail',
'categories',
'tags',
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment