基本上,每个帖子都会出现相同的论文评论。我已经读到了为什么会发生这种情况,但仍然不知道出了什么问题。在
以下是我在页面上看到的:
下面是我的模板代码:
{% block content %}
<p> The post id is: {{ post_object.id}} </p>
<p> The post URL: {{ post_object.get_absolute_url }}
{# DISQUS #}
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'MySiteName'; // required
var disqus_identifier = '{{ post_object.id }}';
var disqus_url = 'http://localhost:8000{{ post_object.get_absolute_url }}';
var disqus_title = '{{ post_object.title }}';
var disqus_developer = 1;
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{% endblock content %}
呈现的HTML:
^{pr2}$如您所见,discus_标识符和discus_url是唯一的。这是怎么回事?在
任何想法或反馈都有帮助!谢谢!在
编辑:好吧,我知道问题出在哪里了。在对位于http://localhost:8000/post/42/
的帖子发表评论后,discus将添加到discus管理员(在“讨论”选项卡下)作为http://localhost:8000/post
的链接
在我的页面上这甚至不是一个有效的URL。当我显式地将链接更改为http://localhost:8000/post/42/
时,它将保存。但是,一个新创建的帖子仍然会显示来自第42篇文章的评论。在
有什么想法?在
安装django-disqus并在模板中使用它。在
将Discus添加到已安装的应用程序中,并将您的Discus api密钥放入您的设置中:
在设置.py在
^{pr2}$在模板中使用取消模板标记:
一些_模板.html在
希望这有帮助。在
{s可以尝试使用一些简单的标记来加载,比如使用^ s模板。只需要:
相关问题 更多 >
编程相关推荐