我有一个内容模型:Category
,有两个类别内容条目。
我正在使用此功能检索:
def categories(request):
contentful_client = contentful.Client(CONTENTFUL_SPACE_ID,
CONTENTFUL_TOKEN_ID)
category_entries = contentful_client.entries()
for entry in category_entries:
print(getattr(entry, 'categoryName', 'not found'))
for entry in category_entries:
print(entry)
count = len(category_entries)
return HttpResponse('There are %d categories' % count)
输出是:
not found
not found
<Entry[category] id='7hzRlNZw9cvKeYBQPGRV9a'>
<Entry[category] id='2ZV3W30qLSosL5PPmKEoD5'>
我想知道为什么该属性categoryName
没有被识别,因为该条目有两个属性categoryName
和categoryBlob
我正在关注的文档以相同的方式执行此操作:
for entry in entries:
print(getattr(entry, 'product_name', 'Not a product'))
Not a product
Not a product
Whisk Beater
Hudson Wall Cup
Not a product
Not a product
Not a product
Not a product
SoSo Wall Clock
Not a product
Not a product
Not a product
Playsam Streamliner Classic Car, Espresso
我错过了什么?