[BUG] TypeError: 'coroutine' object is not subscriptable
See original GitHub issueasync def search(request, keywords: str):
item = await sync_to_async(list)(Movie.objects.all())
if item:
return item
Error code after running
Traceback (most recent call last):
File "D:\Program Files (x86)\Anaconda3\envs\django\lib\site-packages\ninja\operation.py", line 99, in run
result = self.view_func(request, **values)
File "D:\Program Files (x86)\Anaconda3\envs\django\lib\site-packages\ninja\pagination.py", line 145, in view_with_pagination
result = paginator.paginate_queryset(
File "D:\Program Files (x86)\Anaconda3\envs\django\lib\site-packages\ninja\pagination.py", line 69, in paginate_queryset
"items": queryset[offset : offset + limit],
TypeError: 'coroutine' object is not subscriptable
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
python: TypeError: 'coroutine' object is not subscriptable
basically the awaitable returns a (nested) dict and you can retrieve the values from the dict once the await is completed: (await function())...
Read more >TypeError: 'coroutine' object is not subscriptable #825 - GitHub
I get the error TypeError: 'coroutine' object is not subscriptable when I try to read a CSV from S3. It does not occur...
Read more >Nbdev_test_nbs in CI:TypeError: 'coroutine' object is not ...
I only pin to nbconvert==5 , I have jupyter_client= 6.1. 12 and all works fine. (Over-pinning should be avoided like the plague, creates...
Read more >tiangolo/fastapi - Gitter
I'm getting this error: ValueError: [KeyError(<class 'coroutine'>), TypeError("'coroutine' object is not iterable"), TypeError('vars() argument must have ...
Read more >Common Mistakes Using Python3 asyncio
This "coroutine object" will be executed when current EventLoop gets a chance: awaited/yield from is called or all previous tasks are finished. To...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sunboy123 sure, I’ve created a async version for the decorator. Here is the code:
An example:
Please note, with this solution, if you need to use another Pagination class (like
AsyncLimitOffsetPagination
) you need to make that async compatible too.@chrismaille thanks a lot .