[Fixed]-REST Framework: how to serialize objects?

1👍

Error is because your model is not json serializable.

you can see @yuwang comment to follow nested serializer http://www.django-rest-framework.org/api-guide/serializers/#dealing-with-nested-objects

or for now, particular for this case you can change your code to:

@property
def students(self):
    from pupils.models import Pupils
    return list(Pupils.objects.filter(group=self).values())
👤Roshan

Leave a comment