TypeError: 'list' object is not callable

farhatnawaz profile image Farhat Nawaz ・1 min read

I am writing an API in Flask with mongoengine. In my 'search' endpoint, the API receives an 'id' and retrieves all the objects from database against that id. But when I try to return those objects in json form like this:

    return [redemp.to_json for redemp in redemps]

I get the error saying "TypeError: 'list' object is not callable"
What's wrong here?


Editor guide
dkassen profile image
Daniel Kassen

Are you sure that the objects your working with are what you expect? Try putting debuggers in your code around where you suspect the error is occurring and print things out. It is otherwise very hard for us to help you because there is so little information.. :(