django-social-share icon indicating copy to clipboard operation
django-social-share copied to clipboard

ready urls context ?

Open Ahmed7fathi opened this issue 5 years ago • 3 comments
trafficstars

is there a ready urls context like {{ facebook_url }} instead of {% post_to_facebook object_or_url %} i only need a the share link

Ahmed7fathi avatar Mar 22 '20 08:03 Ahmed7fathi

Hi!

You can use {% post_to_facebook_url <object_or_url> %}, and it will populate a variable called {{ facebook_url }} in your context.

fcurella avatar Mar 27 '20 18:03 fcurella

Seems to be dumping all of the template's context for some reason right into the template, as opposed to setting the variable. This appears on my site when I run the code at the bottom:

...<TextNode: '\n\n\n\n'>]>}, {'forloop': {'parentloop': {}, 'counter0': 0, 'counter': 1, 'revcounter': 4, 'revcounter0': 3, 'first': True, 'last': False}, 'post': <Post: test post #2>}, {'post': <Post: test post #2>, 'facebook_url': 'https://www.facebook.com/sharer/sharer.php?u=http%3A//localhost%3A8181/listings/test-post-2/'}]

When I have at the top of my template:

{% load social_share %}

{% post_to_facebook_url post %}


<div class="card border p-2 my-3">
    <div class="row g-0">

Keep in mind this is inside a for loop, outputting the posts.

Any ideas?

johndevor avatar Feb 16 '23 20:02 johndevor

Made a workaround:

{% post_to_facebook_url post as facebook_url_list %}

{{facebook_url_list.facebook_url}}

johndevor avatar Feb 16 '23 21:02 johndevor