Django AttributeError:type object';用户';没有属性';名称';

Django AttributeError:type object';用户';没有属性';名称';,django,python-3.x,django-models,graphql,graphene-python,Django,Python 3.x,Django Models,Graphql,Graphene Python,我刚接触石墨烯,我有这个: from django.contrib.auth.models import User class UserType(DjangoObjectType): class Meta: model = User 基本上,使用Django的用户类给了我这个错误,因为在使用Django用户类之前,我使用的是我自己的用户定义,它工作正常。为什么使用django身份验证框架中的User类会导致标题中提到的错误: 文件“/usr/local/lib/pyt

我刚接触石墨烯,我有这个:

from django.contrib.auth.models import User

class UserType(DjangoObjectType):
    class Meta:
        model = User
基本上,使用Django的用户类给了我这个错误,因为在使用Django用户类之前,我使用的是我自己的用户定义,它工作正常。为什么使用django身份验证框架中的User类会导致标题中提到的错误:

文件“/usr/local/lib/python3.6/site packages/graphql/type/typemap.py”, 第60行,如果map:AttributeError:type对象中的type.name是reducer中的 “用户”没有属性“名称”

我错过什么了吗

问候

PD:我正在使用Django 2.0.4

回溯

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x107c49e18>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
    self.check(display_num_errors=True)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 351, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 397, in check
    for pattern in self.url_patterns:
  File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 536, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/freddy/PycharmProjects/DYD/DYD/urls.py", line 19, in <module>
    from dyd_server.graphql import schema
  File "/Users/freddy/PycharmProjects/DYD/dyd_server/graphql/__init__.py", line 10, in <module>
    schema = graphene.Schema(query=RootQuery, mutation=Mutations)
  File "/usr/local/lib/python3.6/site-packages/graphene/types/schema.py", line 57, in __init__
    self.build_typemap()
  File "/usr/local/lib/python3.6/site-packages/graphene/types/schema.py", line 123, in build_typemap
    schema=self
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 69, in __init__
    super(TypeMap, self).__init__(types)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/typemap.py", line 16, in __init__
    self.update(reduce(self.reducer, types, OrderedDict()))
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 77, in reducer
    return self.graphene_reducer(map, type)
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 107, in graphene_reducer
    return GraphQLTypeMap.reducer(map, internal_type)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/typemap.py", line 80, in reducer
    field_map = type.fields
  File "/usr/local/lib/python3.6/site-packages/graphql/pyutils/cached_property.py", line 16, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/definition.py", line 180, in fields
    return define_field_map(self, self._fields)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/definition.py", line 189, in define_field_map
    field_map = field_map()
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 250, in construct_fields_for_type
    map = self.reducer(map, field.type)
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 77, in reducer
    return self.graphene_reducer(map, type)
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 107, in graphene_reducer
    return GraphQLTypeMap.reducer(map, internal_type)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/typemap.py", line 80, in reducer
    field_map = type.fields
  File "/usr/local/lib/python3.6/site-packages/graphql/pyutils/cached_property.py", line 16, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/definition.py", line 180, in fields
    return define_field_map(self, self._fields)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/definition.py", line 189, in define_field_map
    field_map = field_map()
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 250, in construct_fields_for_type
    map = self.reducer(map, field.type)
  File "/usr/local/lib/python3.6/site-packages/graphene/types/typemap.py", line 78, in reducer
    return GraphQLTypeMap.reducer(map, type)
  File "/usr/local/lib/python3.6/site-packages/graphql/type/typemap.py", line 60, in reducer
    if type.name in map:
AttributeError: type object 'User' has no attribute 'name'
由启动的线程中未处理的异常 回溯(最近一次呼叫最后一次): 包装器中的文件“/usr/local/lib/python3.6/site packages/django/utils/autoreload.py”,第225行 fn(*args,**kwargs) 文件“/usr/local/lib/python3.6/site packages/django/core/management/commands/runserver.py”,第120行,在内部运行 self.check(display\u num\u errors=True) 文件“/usr/local/lib/python3.6/site packages/django/core/management/base.py”,第364行,选中 包括部署检查=包括部署检查, 文件“/usr/local/lib/python3.6/site packages/django/core/management/base.py”,第351行,运行检查 返回检查。运行检查(**kwargs) 文件“/usr/local/lib/python3.6/site packages/django/core/checks/registry.py”,运行检查中的第73行 新建错误=检查(应用程序配置=应用程序配置) 文件“/usr/local/lib/python3.6/site packages/django/core/checks/url.py”,第13行,在check\u url\u config中 返回检查\u分解器(分解器) 文件“/usr/local/lib/python3.6/site packages/django/core/checks/url.py”,第23行,在check\u解析器中 返回检查方法() 文件“/usr/local/lib/python3.6/site packages/django/url/resolvers.py”,第397行,选中 对于self.url_模式中的模式: 文件“/usr/local/lib/python3.6/site packages/django/utils/functional.py”,第36行,在__ res=instance.\uuuu dict\uuuu[self.name]=self.func(实例) 文件“/usr/local/lib/python3.6/site packages/django/url/resolvers.py”,第536行,url_模式 patterns=getattr(self.urlconf_模块,“urlpatterns”,self.urlconf_模块) 文件“/usr/local/lib/python3.6/site packages/django/utils/functional.py”,第36行,在__ res=instance.\uuuu dict\uuuu[self.name]=self.func(实例) urlconf_模块中的文件“/usr/local/lib/python3.6/site packages/django/url/resolvers.py”,第529行 返回导入_模块(self.urlconf_名称) 文件“/usr/local/cillar/python/3.6.5/Frameworks/python.framework/Versions/3.6/lib/python3.6/importlib/__init____;.py”,第126行,在导入模块中 return _bootstrap._gcd_import(名称[级别:],包,级别) 文件“”,第994行,在_gcd_导入中 文件“”,第971行,在_find_和_load中 文件“”,第955行,在“查找”和“加载”中解锁 文件“”,第665行,在“加载”中 exec_模块中第678行的文件“” 文件“”,第219行,在“调用”中,删除了“帧” 文件“/Users/freddy/PycharmProjects/DYD/DYD/url.py”,第19行,在 从dyd_server.graphql导入架构 文件“/Users/freddy/PycharmProjects/DYD/DYD_server/graphql/_init__uuu.py”,第10行,在 schema=graphene.schema(查询=根查询,突变=突变) 文件“/usr/local/lib/python3.6/site packages/graphene/types/schema.py”,第57行,在__ self.build_typemap() 文件“/usr/local/lib/python3.6/site packages/graphene/types/schema.py”,第123行,内置类型图 模式=自我 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第69行,在__ super(类型映射,self)。\uuuu init\uuuu(类型) 文件“/usr/local/lib/python3.6/site packages/graphql/type/typemap.py”,第16行,在__ update(reduce(self.reducer,type,OrderedDict())) 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第77行,在reducer中 返回自石墨烯还原剂(图,类型) 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第107行,graphene\u中 返回图形QLTypeMap.reducer(映射,内部类型) 文件“/usr/local/lib/python3.6/site packages/graphql/type/typemap.py”,第80行,在reducer中 field\u map=type.fields 文件“/usr/local/lib/python3.6/site packages/graphql/pyutils/cached_property.py”,第16行,在__ value=obj.\uuuu dict\uuuu[self.func.\uuuuuu name\uuuuu]=self.func(obj) 文件“/usr/local/lib/python3.6/site packages/graphql/type/definition.py”,第180行,在字段中 返回定义字段映射(self,self.\u字段) 文件“/usr/local/lib/python3.6/site packages/graphql/type/definition.py”,第189行,在define\u field\u映射中 字段映射=字段映射() 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第250行,用于类型的构造字段 map=self.reducer(map,field.type) 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第77行,在reducer中 返回自石墨烯还原剂(图,类型) 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第107行,graphene\u中 返回图形QLTypeMap.reducer(映射,内部类型) 文件“/usr/local/lib/python3.6/site packages/graphql/type/typemap.py”,第80行,在reducer中 field\u map=type.fields 文件“/usr/local/lib/python3.6/site packages/graphql/pyutils/cached_property.py”,第16行,在__ value=obj.\uuuu dict\uuuu[self.func.\uuuuuu name\uuuuu]=self.func(obj) 文件“/usr/local/lib/python3.6/site packages/graphql/type/definition.py”,第180行,在字段中 返回定义字段映射(self,self.\u字段) 文件“/usr/local/lib/python3.6/site packages/graphql/type/definition.py”,第189行,在define\u field\u映射中 字段映射=字段映射() 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第250行,用于类型的构造字段 map=self.reducer(map,field.type) 文件“/usr/local/lib/python3.6/site packages/graphene/types/typemap.py”,第78行,在reducer中 返回图形QLTypeMap.reducer(映射,类型)
user = graphene.Field(UserType)
user = graphene.Field(User)