如何在Django模板中显示搜索api返回结果的doc id?

2024-06-16 10:49:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用appenginesearchapi在文档中搜索。返回的结果显示在django模板上,如下所示

{% for item in results %}
    {{item.id.0.value}}
    {{item.name.0.value}}
{% endfor %}

我可以显示模板中的所有字段,但结果的文档id除外。有人能帮我弄清楚如何在模板中显示文档id吗?你知道吗


Tags: djangoin文档模板idforvalueitem
1条回答
网友
1楼 · 发布于 2024-06-16 10:49:28

根据documentation

...you can examine the id attribute of the result to discover the doc_id that was generated.

因此,示例中的.id属性实际上就是您要查找的doc\u id。你知道吗

相关问题 更多 >