django TypeError: 'coroutine' object is not iterable

Viewed 934

Here is the code snippet. I am fetching data from fatabase asynchronusly.

but, I am getting below error

            for contract in contracts:
            TypeError: 'coroutine' object is not iterable
        


   
    @sync_to_async
    def get_all_contract_objects():
        return EthereumContract.objects.all()


    def compute_topics_to_eventabis() -> Dict:
        "Loop through all contracts in our DB and compute topics to ABI mapping"
        topics_to_event_abis = {}
        contracts = get_all_contract_objects()
        for contract in contracts:
            print(contract)
        return topics_to_event_abis

    

This part only need to fix. so that i can loop over contracts and print it.

0 Answers
Related