Kasper Fredenslund Kasper Fredenslund - 6 months ago 18
Javascript Question

Disqus comment box not showing (at all)

When following the tutorial found on Disqus the comment-box won't render. It seems to be setup correct from the admin found on disqus.

var disqus_config = function () {
this.page.url = {{request.build_absolute_uri}}; // {{request.build_absolute_uri}} is what is says | Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = {{instance.id}}; // {{instance.id}} article unique ID | Replace PAGE_IDENTIFIER with your page's unique identifier variable
};


The
{{request.build_absolute_uri}}
returns
http://localhost:8000/posts/*[post_title]*/

And the page identifier
instance.id
is an integer incrementing by one for each post (eg 2)

I have also set the domain on discuss to be
http://localhost:8000/posts/
(since as of now it raises a 404 error when not specifying a sub-url)

(function() {
var d = document, s = d.createElement('script');

s.src = '//trydjango19.disqus.com/embed.js';

s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();


I have also linked the comment count JS file, as well as appending #disqus_thread to all links on the homepage

Answer

Do you get valid javascript from this?

this.page.url = {{request.build_absolute_uri}};

I would expect that this.page.url should be a string. In which case you probably have to wrap it in quotes. instance.id should probably be a string well, since that's how it's done in the examples in the disqus docs.

this.page.url = "{{request.build_absolute_uri}}";
this.page.identifier = "{{instance.id}}";