Django 中的社交媒体链接

问题描述 投票:0回答:3

我想在 Django 模板中的帖子末尾设置一个社交链接。 如何使用 Django 帖子中的社交媒体链接在社交中分享我的帖子?

python django django-templates facebook-social-plugins python-social-auth
3个回答
12
投票

查看 django-social-share (https://github.com/fcurella/django-social-share) 或 django-socialsharing (https://github.com/lettertwo/django-socialsharing)。

更多内容可以在这里找到:https://www.djangopackages.com/grids/g/social/


4
投票

我发现了一些东西。对于 Google、Linkedin、Facebook:

 <a href="https://plus.google.com/share?url=http://your-domain{{ request.get_full_path|urlencode }}"></a>
 <a href="http://www.linkedin.com/shareArticle?url=http://your-domain{{ request.get_full_path|urlencode }}&title=<your title>&summary=<your desc>&source=http://your-domain"></a>
 <a href="http://www.facebook.com/sharer/sharer.php?u=http://your-domain{{ request.get_full_path|urlencode }}"></a>

此外,这个插件(django-social-share)非常好。 您可以通过以下方式安装:

pip install django-social-share

要使用此插件,请参阅文档页面


0
投票

我发现以下链接适用于 Whatsap、LinkedIn、Facebook、Twitter。

<a href="https://api.whatsapp.com/send?text={{ request.build_absolute_uri }}" style="margin-right: 10px;">
                                <img data-src="#" class=" lazyloaded" loading="lazy" alt="Whatsapp" width="35" height="35" src="#">
                                
                            </a>
                            <a href="https://www.linkedin.com/shareArticle?mini=true&amp;url={{ request.build_absolute_uri }}" style="margin-right: 10px;">
                                <img data-src="#" class=" lazyloaded" loading="lazy" alt="linkedin" width="35" height="35" src="#">
                                
                            </a>
                            <a href="https://www.facebook.com/sharer.php?u={{ request.build_absolute_uri }}" style="margin-right: 10px;">
                                <img data-src="#" class=" lazyloaded" loading="lazy" alt="facebook" width="35" height="35" src="#">
                                
                            </a>
                            <a href="https://twitter.com/intent/tweet?text={{ request.build_absolute_uri }}">
                                <img data-src="#" class=" lazyloaded" loading="lazy" alt="twitter" width="35" height="35" src="#">
                                
                            </a>

如果你想获得 abosulte url,你可以使用 {{ request.build_ablsolute_uri }} 或者你可以将你自己的 url 放在该字段中。另外,请注意,对于 linkedIn 来说,这可能在本地主机中不起作用,但在我部署后对我有用.

© www.soinside.com 2019 - 2024. All rights reserved.