from rest_framework import serializers

from apps.contribution.models import Repository


class RepositorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Repository
        fields = ('id', 'name', 'description', 'url', 'updated_at')

from rest_framework import serializers

from apps.contribution.models import Repository, RepositoryLanguage


class RepositoryLanguagesSerializer(serializers.ModelSerializer):
    class Meta(object):
        model = RepositoryLanguage
        fields = ('type', 'size')


class RepositorySerializer(serializers.ModelSerializer):
    languages = RepositoryLanguagesSerializer(many=True)

    class Meta:
        model = Repository
        fields = ('id', 'name', 'description', 'url', 'updated_at', 'languages')

Add languages to api endpoint
Add languages to api endpoint

  from rest_framework import serializers
  
- from apps.contribution.models import Repository
+ from apps.contribution.models import Repository, RepositoryLanguage
+ 
+ 
+ class RepositoryLanguagesSerializer(serializers.ModelSerializer):
+     class Meta(object):
+         model = RepositoryLanguage
+         fields = ('type', 'size')
  
  
  class RepositorySerializer(serializers.ModelSerializer):
+     languages = RepositoryLanguagesSerializer(many=True)
+ 
      class Meta:
          model = Repository
-         fields = ('id', 'name', 'description', 'url', 'updated_at')
+         fields = ('id', 'name', 'description', 'url', 'updated_at', 'languages')
  
Add languages to api endpoint
## Code Before:
from rest_framework import serializers

from apps.contribution.models import Repository


class RepositorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Repository
        fields = ('id', 'name', 'description', 'url', 'updated_at')

## Instruction:
Add languages to api endpoint
## Code After:
from rest_framework import serializers

from apps.contribution.models import Repository, RepositoryLanguage


class RepositoryLanguagesSerializer(serializers.ModelSerializer):
    class Meta(object):
        model = RepositoryLanguage
        fields = ('type', 'size')


class RepositorySerializer(serializers.ModelSerializer):
    languages = RepositoryLanguagesSerializer(many=True)

    class Meta:
        model = Repository
        fields = ('id', 'name', 'description', 'url', 'updated_at', 'languages')
