Skip to content

Commit f0d6a18

Browse files
committed
fix: Check django version before assigning paginate_queryset
1 parent bfa8cba commit f0d6a18

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ninja_extra/pagination/operations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
if TYPE_CHECKING: # pragma: no cover
1818
from ninja_extra.controllers import ControllerBase
1919

20+
import django
21+
2022

2123
class PaginatorOperation:
2224
def __init__(
@@ -110,10 +112,11 @@ async def as_view(
110112
request = request_or_controller
111113
params = dict(kw)
112114
params["request"] = request
113-
115+
is_supported_async_orm = django.VERSION >= (4, 2)
114116
paginate_queryset = (
115117
self.paginator.apaginate_queryset
116118
if isinstance(self.paginator, AsyncPaginationBase)
119+
and is_supported_async_orm
117120
else cast(Callable, sync_to_async(self.paginator.paginate_queryset))
118121
)
119122
return await paginate_queryset(items, **params)

0 commit comments

Comments
 (0)