TypeError: 'list' object is not callable

github logo ・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?

twitter logo DISCUSS (1)
markdown guide
 

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

Classic DEV Post from Jan 31

What are the least intuitive fundamentals and best practices in software development?

Some things we do kind of make sense in and of themself. Some things have evolv...

Farhat Nawaz profile image

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️