How to use the graphene-django.graphene_django.utils.DJANGO_FILTER_INSTALLED function in graphene-django

To help you get started, we’ve selected a few graphene-django examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-python / graphene / graphene-django / graphene_django / filter / __init__.py View on Github external
import warnings
from ..utils import DJANGO_FILTER_INSTALLED

if not DJANGO_FILTER_INSTALLED:
    warnings.warn(
        "Use of django filtering requires the django-filter package "
        "be installed. You can do so using `pip install django-filter`", ImportWarning
    )
else:
    from .fields import DjangoFilterConnectionField
    from .filterset import GrapheneFilterSet, GlobalIDFilter, GlobalIDMultipleChoiceFilter

    __all__ = ['DjangoFilterConnectionField', 'GrapheneFilterSet',
               'GlobalIDFilter', 'GlobalIDMultipleChoiceFilter']
github graphql-python / graphene / graphene-django / graphene_django / fields.py View on Github external
def get_connection_field(*args, **kwargs):
    if DJANGO_FILTER_INSTALLED:
        from .filter.fields import DjangoFilterConnectionField
        return DjangoFilterConnectionField(*args, **kwargs)
    return ConnectionField(*args, **kwargs)
github graphql-python / graphene / graphene-django / graphene_django / types.py View on Github external
# Also ensure initialization is only performed for subclasses of
        # DjangoObjectType
        if not is_base_type(bases, DjangoObjectTypeMeta):
            return type.__new__(cls, name, bases, attrs)

        defaults = dict(
            name=name,
            description=attrs.pop('__doc__', None),
            model=None,
            local_fields=None,
            only_fields=(),
            exclude_fields=(),
            interfaces=(),
            registry=None
        )
        if DJANGO_FILTER_INSTALLED:
            # In case Django filter is available, then
            # we allow more attributes in Meta
            defaults.update(
                filter_fields=(),
                filter_order_by=(),
            )

        options = Options(
            attrs.pop('Meta', None),
            **defaults
        )
        if not options.registry:
            options.registry = get_global_registry()
        assert isinstance(options.registry, Registry), (
            'The attribute registry in {}.Meta needs to be an instance of '
            'Registry, received "{}".'