[Answered ]-Django-disqus: disqus comment box on

1👍

Disqus is designed to load one Disqus postbox per page. Disqus uses the page URL as a unique identifier and only one Disqus embed can be associated with a single URL. If more than one Disqus embed is present in the source code of a page, only one embed will load.

There is a way to reload the disqus embed with different identifiers:

  DISQUS.reset({
  reload: true,
  config: function () {  
    this.page.identifier = "newidentifier";  
    this.page.url = "http://example.com/#!newthread";
  }
});

However, this method is still only used with one embed per page.

1👍

This is solved but I’d like to show a different approach by using django-disqus. The last line is the one that gets you the right comments for the specific page/object.

Install django-disqus and use it in your templates.

pip install django-disqus

Add disqus to your INSTALLED_APPS and put your disqus api key in your settings:

settings.py

INSTALLED_APPS = (
    ...
    'disqus',
    ...
)

DISQUS_API_KEY = 'YOUR_SECRET_API_KEY'
DISQUS_WEBSITE_SHORTNAME = 'YOUR_WEBSITE_SHORTNAME'

Use disqus template tags in your templates:

some_template.html

# load the tags
{% load disqus_tags %}
# get comments for your website
{% disqus_show_comments "YOUR_WEBSITE_SHORTNAME" %}
# get the url for the current object to get the right comments
{% set_disqus_url object.get_absolute_url %}

Leave a comment