mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-04 12:23:13 +03:00
Use maybe_queryset in DjangoFilterConnectionField
In our projects we've found a need to inherit from DjangoFilterConnectionField in order to customize the queryset. When passing the queryset into "connection_resolver", an error was raised about "get_queryset" not existing. This is due to the assumption that the "base_manager" is always a manager. Using "maybe_queryset" resolves the issue.
This commit is contained in:
parent
283bccf9d3
commit
9ef31d849d
|
@ -2,7 +2,9 @@ from collections import OrderedDict
|
|||
from functools import partial
|
||||
|
||||
from graphene.types.argument import to_arguments
|
||||
|
||||
from ..fields import DjangoConnectionField
|
||||
from ..utils import maybe_queryset
|
||||
from .utils import get_filtering_args_from_filterset, get_filterset_class
|
||||
|
||||
|
||||
|
@ -72,7 +74,7 @@ class DjangoFilterConnectionField(DjangoConnectionField):
|
|||
filter_kwargs = {k: v for k, v in args.items() if k in filtering_args}
|
||||
qs = filterset_class(
|
||||
data=filter_kwargs,
|
||||
queryset=default_manager.get_queryset()
|
||||
queryset=maybe_queryset(default_manager)
|
||||
).qs
|
||||
|
||||
return super(DjangoFilterConnectionField, cls).connection_resolver(
|
||||
|
|
Loading…
Reference in New Issue
Block a user