如何将社交共享链接添加到DetailView?

2024-06-17 18:22:54 发布

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

如何在Django中为我的网站构建添加社交共享功能。我在SO中看到了一个类似的问题,但没有帮助(下面我解释了原因?),6年前有人问我,我想这些年后肯定有更好的方法。你知道吗

我试过使用addthis,它既优雅又易于使用,但当我在Facebook上分享帖子时,这就是问题所在。你知道吗

enter image description here

而且它也没有统计分享一个帖子的次数。你知道吗

我还尝试了其他的ways要么我不明白,要么效果不好。 请帮我做这个。非常感谢你。你知道吗

编辑: 我得到这个错误。添加<a href="https://www.facebook.com/sharer/sharer.php?u={{ request.get_full_path|urlencode }}&t={{ object.title }}">Share on Facebook</a>

enter image description here


Tags: django方法功能编辑facebookso网站原因
1条回答
网友
1楼 · 发布于 2024-06-17 18:22:54

将此用于Facebook: {% with base_url="http://example.com" %} <a href="https://www.facebook.com/sharer/sharer.php?u={{ base_url|urlencode }}{{ request.get_full_path|urlencode }}&t={{ object.title }}">Share on Facebook</a> {% endwith %}

对于Twitter: {% with base_url="http://example.com" %} <a href="https://twitter.com/share?text={{ user.username }}&url={{ base_url|urlencode }}{{ request.get_full_path|urlencode}}">Share on Twitter</a> {% endwith %}

对于Linkedin:使用this

相关问题 更多 >