根本无法理解出了什么问题:无法为石墨烯设置“SCHEMA”导入“ss.schema.schema”。AttributeError:类型对象“查询”没有属性“_meta”。
这是我在应用程序文件“pages.schema.py”中的查询类:
class Query(graphene.AbstractType):
user = graphene.relay.Node.Field(UserNode)
users = DjangoFilterConnectionField(UserNode, filterset_class=UserFilter)
这是根模式文件“ss.schema.py::
import graphene
import pages.schema
class Query(pages.schema.Query, graphene.ObjectType):
pass
class Mutation(pages.schema.Mutation, graphene.ObjectType):
pass
schema = graphene.Schema(query=Query, mutation=Mutation)
这是完整的回溯:
Environment:
Request Method: GET
Request URL: http://95.213.203.11/graphql
Django Version: 1.11.5
Python Version: 3.5.2
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'ws4redis',
'graphene_django',
'pages']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/root/ss/lib/python3.5/site-packages/graphene_django/settings.py" in import_from_string
74. module = importlib.import_module(module_path)
File "/root/ss/lib/python3.5/importlib/__init__.py" in import_module
126. return _bootstrap._gcd_import(name[level:], package, level)
File "./ss/schema.py" in <module>
3. import pages.schema
File "./pages/schema.py" in <module>
130. schema = graphene.Schema(query=Query, mutation=Mutation)
File "/root/ss/lib/python3.5/site-packages/graphene/types/schema.py" in __init__
27. ).format(query)
File "/root/ss/lib/python3.5/site-packages/graphene/utils/subclass_with_meta.py" in __repr__
11. return cls._meta.name
During handling of the above exception (type object 'Query' has no attribute '_meta'), another exception occurred:
File "/root/ss/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/root/ss/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/root/ss/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/root/ss/lib/python3.5/site-packages/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/root/ss/lib/python3.5/site-packages/django/views/generic/base.py" in view
62. self = cls(**initkwargs)
File "/root/ss/lib/python3.5/site-packages/graphene_django/views.py" in __init__
70. schema = graphene_settings.SCHEMA
File "/root/ss/lib/python3.5/site-packages/graphene_django/settings.py" in __getattr__
116. val = perform_import(val, attr)
File "/root/ss/lib/python3.5/site-packages/graphene_django/settings.py" in perform_import
60. return import_from_string(val, setting_name)
File "/root/ss/lib/python3.5/site-packages/graphene_django/settings.py" in import_from_string
78. raise ImportError(msg)
Exception Type: ImportError at /graphql
Exception Value: Could not import 'ss.schema.schema' for Graphene setting 'SCHEMA'. AttributeError: type object 'Query' has no attribute '_meta'.
任何建议如何解决它?