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