0

I googled and searched similar questions on Stackoverflow, but couldn't make it due to lack of details. I know how to get the current url {{ request.build_absolute_uri }} but I don't know how to use this to share the content in different social apps?

Mir Stephen
  • 1,758
  • 4
  • 23
  • 54
  • Did you try plugins like this one? https://pypi.org/project/django-social-widgets/ – Pitto Jul 01 '20 at 17:33
  • I tried, but it lacks detail, I get errors while trying to impliment it – Mir Stephen Jul 01 '20 at 17:37
  • I added `{% social_widget_render "twitter/share_button.html" href="http://www.twitter.com" username="BillGates" %}` in template, but getting this error `Invalid block tag on line 29: 'social_widget_render', expected 'endblock'. Did you forget to register or load this tag?` – Mir Stephen Jul 01 '20 at 17:43
  • https://stackoverflow.com/questions/35054230/django-did-you-forget-to-register-or-load-this-tag – Pitto Jul 01 '20 at 18:56
  • I know what is that error and I don't think this link helps – Mir Stephen Jul 01 '20 at 19:25
  • https://github.com/creafz/django-social-widgets/tree/master/example_project – Pitto Jul 01 '20 at 20:10

1 Answers1

0

It took me a while to figure out how to use django-social-widgets and here are possible Errors you may encounter and their solutions:

  1. Python Django custom template tags register.assignment_tag not working

AttributeError: 'Library' object has no attribute 'assignment_tag'

Solution:

rename assignment_tag to simple_tag. Since, former is deprecated and simple_tag is used instead.

  1. Error: TypeError context must be a dict rather than Context

    try:
        t = loader.get_template(template)
        return t.render(Context(kwargs))
    except TemplateDoesNotExist:
        return ''
    

replace above code with:

try:
    t = loader.get_template(template)
    return t.render(kwargs)   # here

Mir Stephen
  • 1,758
  • 4
  • 23
  • 54