我加入disqus我Django应用程序并不能得到它加载的每个页面的评论一个新的线程。
我已经尝试了一切,跟着文档,其中规定的javascript模板使用前设置在disqus的变量。
这是我的“post_detail.html”需要disqus评论:
{% extends 'base.html' %}
{% block content %}
<div class="post-entry">
<h2>{{ post.title }}</h2>
<p>{{ post.body|safe }}</p>
</div>
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
var disqus_config = function () {
this.page.url = '{{ request.build_absolute_uri }}'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '{{ request.get_full_path }}'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
this.page.title = '{{ post.title }}'
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://bytewise-com.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{% endblock content %}
在该函数的变量设置正确,每https://help.disqus.com/developer/javascript-configuration-variables
...
this.page.url = '{{ request.build_absolute_uri }}';
this.page.identifier = '{{ request.get_full_path }}';
...
这里是我的浏览器响应加载页面获得,所以我知道的变量是正确加载。
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
var disqus_config = function () {
this.page.url = 'http://127.0.0.1:8000/post/1/'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '/post/1/'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
this.page.title = 'Testing the post function'
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://bytewise-com.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
我试图改变变量手动过,以确保它们完全是独一无二的。使用Django的disqus包和它的模板标签,没有结果也试过。
为什么同样的话仍然出现在我的其他职位?
是否有任何与每个职位引用“post_detail.html”模板?
这方面的工作了几个小时,任何帮助表示赞赏。
我认为disqus管理页面,它显示http://127.0.0.1:8000/post为主线网址,编辑它给了我关于无效URL格式错误。似乎有些奇怪我,所以我删除了网站和意见。
改变可变到:
this.page.url = '{{ request.build_absolute_uri }}.html'
无论出于何种原因disqus似乎与此多,不知道这是为了达成一致,但它似乎是现在的工作很好。