从模型创建 graphene-django 接口
Create graphene-django interface from models
我正在使用 graphene-django,我想创建四个接口,每个接口代表 Django 中的模型,我将从一个模型开始:
class TestInterface(graphene.Interface):
items = graphene.Field(models.Test)
但是我一直收到这个错误:
AttributeError: type object 'Test' has no attribute 'name'
有什么想法吗?
graphene.Field
的参数应该是 class 继承自 DjangoObjectType
而 而不是 Django 模型,例如
class TestType(DjangoObjectType):
class Meta:
model = Test
我正在使用 graphene-django,我想创建四个接口,每个接口代表 Django 中的模型,我将从一个模型开始:
class TestInterface(graphene.Interface):
items = graphene.Field(models.Test)
但是我一直收到这个错误:
AttributeError: type object 'Test' has no attribute 'name'
有什么想法吗?
graphene.Field
的参数应该是 class 继承自 DjangoObjectType
而 而不是 Django 模型,例如
class TestType(DjangoObjectType):
class Meta:
model = Test