Graphene-django: 2.5.0 to 2.6.0 error: TypeError: issubclass() arg 1 must be a class

Created on 2 Oct 2019  路  4Comments  路  Source: graphql-python/graphene-django

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.

 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")

Most helpful comment

I also didn't realise that that was a feature! I've created PR to fix it: https://github.com/graphql-python/graphene-django/pull/885

Sorry for the inconvenience @kayluhb and thanks @NateScarlet for figuring out the case, it made fixing it very easy.

All 4 comments

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.

I also didn't realise that that was a feature! I've created PR to fix it: https://github.com/graphql-python/graphene-django/pull/885

Sorry for the inconvenience @kayluhb and thanks @NateScarlet for figuring out the case, it made fixing it very easy.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MilanRgm picture MilanRgm  路  3Comments

artofhuman picture artofhuman  路  3Comments

ZuluPro picture ZuluPro  路  3Comments

timothyjlaurent picture timothyjlaurent  路  3Comments

x9sheikh picture x9sheikh  路  4Comments