gpt4 book ai didi

python - 在 App Engine 中实现 'Infinite Scrolling'

转载 作者:行者123 更新时间:2023-11-28 21:26:51 24 4
gpt4 key购买 nike

基本上,我有一个个人资料页面,其中显示了评论。我想显示 10 个帖子,然后在用户滚动到页面底部时再加载 10 个帖子(比如 facebook)。

我只是想知道最好的方法是什么?

我现在拥有的是一个查询对象:

 posts = db.GqlQuery("select * from Profile_Comments WHERE name_of_profile =:1 order by date_created desc", profile_id)

我的 jinja 模板中的 for 循环用于获取帖子:

{% for post_tmp in posts %}

{{post_tmp.post.replace('\r\n', '<br>') | safe }}

{% endfor %}

有人知道怎么做吗?谢谢!!!

最佳答案

一种选择是使用类似 this one 的工具/插件,它将通过查找上一个/下一个链接并在用户滚动到足够远时在运行时自动加载和包含它们来“逐步增强”您的页面。

当然,你也可以自己做。无论哪种情况,您都应该了解 App Engine 中的游标,这将使您能够获取后续结果页面,而数据存储区不必跳过已查看的结果。

关于python - 在 App Engine 中实现 'Infinite Scrolling',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12133976/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com