DEV Community

Farhat Nawaz
Farhat Nawaz

Posted on

TypeError: 'list' object is not callable

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]
Enter fullscreen mode Exit fullscreen mode

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

Top comments (1)

Collapse
 
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.. :(