[英]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
的參數應該是從DjangoObjectType
繼承的類,而不是 Django模型,例如
class TestType(DjangoObjectType):
class Meta:
model = Test
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.