1👍
✅
Read more about nested serializers http://www.django-rest-framework.org/api-guide/serializers/#dealing-with-nested-objects. You need to add TaskSerilizer
to your ProjectSerializer
from rest_framework.serializers import ModelSerializer
from api.models import Project, Task
class TaskSerializer(ModelSerializer):
class Meta:
model = Task
class ProjectSerializer(ModelSerializer):
task = TaskSerializer(many=True)
class Meta:
model = Project
fields = (
'id',
'name',
'task'
)
Source:stackexchange.com