diff --git a/graphene_django/fields.py b/graphene_django/fields.py index 4a85f57..e1972c7 100644 --- a/graphene_django/fields.py +++ b/graphene_django/fields.py @@ -156,8 +156,8 @@ class DjangoConnectionField(ConnectionField): # AssertionError after = min(get_offset_with_default(args.get("after"), -1) + 1, list_length) - if max_limit is not None and args.get("first", None) == None: - if args.get("last", None) != None: + if max_limit is not None and args.get("first", None) is None: + if args.get("last", None) is not None: after = list_length - args["last"] else: args["first"] = max_limit diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py index 64453ea..b3333bf 100644 --- a/graphene_django/filter/filterset.py +++ b/graphene_django/filter/filterset.py @@ -1,7 +1,6 @@ import itertools from django.db import models -from django_filters import Filter, MultipleChoiceFilter from django_filters.filterset import BaseFilterSet, FilterSet from django_filters.filterset import FILTER_FOR_DBFIELD_DEFAULTS diff --git a/graphene_django/filter/utils.py b/graphene_django/filter/utils.py index 9922cc8..ef18a86 100644 --- a/graphene_django/filter/utils.py +++ b/graphene_django/filter/utils.py @@ -1,12 +1,9 @@ import graphene - from django import forms +from django_filters.utils import get_model_field -from django_filters.utils import get_model_field, get_field_parts -from django_filters.filters import Filter, BaseCSVFilter - -from .filterset import custom_filterset_factory, setup_filterset from .filters import ArrayFilter, ListFilter, RangeFilter +from .filterset import custom_filterset_factory, setup_filterset from ..forms import GlobalIDFormField, GlobalIDMultipleChoiceField diff --git a/graphene_django/forms/mutation.py b/graphene_django/forms/mutation.py index cc7d647..e56c99c 100644 --- a/graphene_django/forms/mutation.py +++ b/graphene_django/forms/mutation.py @@ -14,10 +14,6 @@ from graphene.types.utils import yank_fields_from_attrs from graphene_django.constants import MUTATION_ERRORS_FLAG from graphene_django.registry import get_global_registry - -from django.core.exceptions import ValidationError -from django.db import connection - from ..types import ErrorType from .converter import convert_form_field diff --git a/graphene_django/forms/types.py b/graphene_django/forms/types.py index 5005040..74e275e 100644 --- a/graphene_django/forms/types.py +++ b/graphene_django/forms/types.py @@ -1,3 +1 @@ -import graphene - from ..types import ErrorType # noqa Import ErrorType for backwards compatability diff --git a/graphene_django/types.py b/graphene_django/types.py index 53c4d23..d272412 100644 --- a/graphene_django/types.py +++ b/graphene_django/types.py @@ -2,11 +2,8 @@ import warnings from collections import OrderedDict from typing import Type -from django.db.models import Model -from django.utils.functional import SimpleLazyObject - import graphene -from graphene import Field +from django.db.models import Model from graphene.relay import Connection, Node from graphene.types.objecttype import ObjectType, ObjectTypeOptions from graphene.types.utils import yank_fields_from_attrs @@ -21,7 +18,6 @@ from .utils import ( is_valid_django_model, ) - ALL_FIELDS = "__all__" @@ -108,12 +104,7 @@ def validate_fields(type_, model, fields, only_fields, exclude_fields): ( 'Excluding the custom field "{field_name}" on DjangoObjectType "{type_}" has no effect. ' 'Either remove the custom field or remove the field from the "exclude" list.' - ).format( - field_name=name, - app_label=model._meta.app_label, - object_name=model._meta.object_name, - type_=type_, - ) + ).format(field_name=name, type_=type_) ) else: if not hasattr(model, name): @@ -232,7 +223,7 @@ class DjangoObjectType(ObjectType): django_fields = yank_fields_from_attrs( construct_fields(model, registry, fields, exclude, convert_choices_to_enum), - _as=Field, + _as=graphene.Field, ) if use_connection is None and interfaces: