[Solved]-<django.db.models.fields.related.RelatedManager object at 0x7ff4e003d1d0> is not JSON serializable



In my case, having one class method at model level.

def documents(self):
    return [{
    } for doc in self.documents.all()] 

and i am using a related_name on documents on last line.

The related_name attribute specifies the name of the reverse relation from the User model back to your model.


earlier, I was using documents as the method name which is also related_name


you can not use related_name as your method name.

so use any other name

πŸ‘€Jamil Noyda


You need to perform a query to get serializable data, when you have a relationship for example you can do something like this:

my_object.relatedmodel_set  # This a RelatedManager

But if you do:

my_object.relatedmodel_set.all()  # This is queryset

Leave a comment