Repository: graphql-python/graphene-django

Issue:
2.5.0 to 2.6.0 error:  TypeError: issubclass() arg 1 must be a class
Hello,

Thanks for all the work on the new release.

I am however getting this error when upgrading to 2.6.0 from 2.5.0 and I just wanted to make sure I understand the change.

```py
 Traceback (most recent call last):
   File "src/manage.py", line 22, in <module>
     execute_from_command_line(sys.argv)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
     utility.execute()
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/management/base.py", line 361, in execute
     self.check()
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
     include_deployment_checks=include_deployment_checks,
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 65, in _run_checks
     issues.extend(super()._run_checks(**kwargs))
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
     return checks.run_checks(**kwargs)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
     new_errors = check(app_configs=app_configs)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/contrib/admin/checks.py", line 111, in check_dependencies
     if not _contains_subclass('django.contrib.auth.middleware.AuthenticationMiddleware', settings.MIDDLEWARE):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/contrib/admin/checks.py", line 43, in _contains_subclass
     candidate_cls = import_string(path)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
     module = import_module(module_path)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/importlib/__init__.py", line 127, in import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
   File "/app/src/ems_api/middleware.py", line 5, in <module>
     from ems.schema import loaders as ems_loaders, nodes
   File "/app/src/ems/schema/nodes.py", line 44, in <module>
     class BenefitSetNode(graphene_django.DjangoObjectType):
   File "/app/src/ems/schema/nodes.py", line 48, in BenefitSetNode
     benefits = fields.DjangoListField("ems.schema.nodes.BenefitNode")
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/graphene_django/fields.py", line 23, in __init__
     _type, DjangoObjectType
 TypeError: issubclass() arg 1 must be a class
```

Does this mean I can no longer pass strings into `DjangoListField`?

e.g. `benefits = fields.DjangoListField("ems.schema.nodes.BenefitNode")`


Discussion:
This should caused by #732 .
Don't know why dynamic type support is dropped for `DjangoListField`.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Wasn't aware this was a feature at one point. Reopening for now, we should open an issue to make this an official feature/enhancement with unit testing.

Resolving patch:
diff --git a/graphene_django/fields.py b/graphene_django/fields.py
--- a/graphene_django/fields.py
+++ b/graphene_django/fields.py
@@ -1,5 +1,6 @@
 from functools import partial
 
+import six
 from django.db.models.query import QuerySet
 from graphql_relay.connection.arrayconnection import connection_from_list_slice
 from promise import Promise
@@ -19,19 +20,23 @@ def __init__(self, _type, *args, **kwargs):
         if isinstance(_type, NonNull):
             _type = _type.of_type
 
+        # Django would never return a Set of None  vvvvvvv
+        super(DjangoListField, self).__init__(List(NonNull(_type)), *args, **kwargs)
+
         assert issubclass(
-            _type, DjangoObjectType
+            self._underlying_type, DjangoObjectType
         ), "DjangoListField only accepts DjangoObjectType types"
 
-        # Django would never return a Set of None  vvvvvvv
-        super(DjangoListField, self).__init__(List(NonNull(_type)), *args, **kwargs)
+    @property
+    def _underlying_type(self):
+        _type = self._type
+        while hasattr(_type, "of_type"):
+            _type = _type.of_type
+        return _type
 
     @property
     def model(self):
-        _type = self.type.of_type
-        if isinstance(_type, NonNull):
-            _type = _type.of_type
-        return _type._meta.model
+        return self._underlying_type._meta.model
 
     @staticmethod
     def list_resolver(django_object_type, resolver, root, info, **args):


Test patch:
diff --git a/graphene_django/tests/test_fields.py b/graphene_django/tests/test_fields.py
--- a/graphene_django/tests/test_fields.py
+++ b/graphene_django/tests/test_fields.py
@@ -19,6 +19,12 @@ class TestType(ObjectType):
         with pytest.raises(AssertionError):
             list_field = DjangoListField(TestType)
 
+    def test_only_import_paths(self):
+        list_field = DjangoListField("graphene_django.tests.schema.Human")
+        from .schema import Human
+
+        assert list_field._type.of_type.of_type is Human
+
     def test_non_null_type(self):
         class Reporter(DjangoObjectType):
             class Meta: