如何将 django-disqus 应用程序集成到博客中
您好,我的客户非常希望将 django disqus 集成到我们为他们构建的博客中。我偶然发现了 https://github.com/arthurk/django-disqus django disqus 应用程序,但无法相信我的运气,我很快就启动并运行了这个,一切似乎都工作正常,我正在发布评论等,但它似乎没有正确识别,因为一篇博客文章的 object.id 发布的评论出现在所有帖子中出博客。
拥有的所有博客文章的索引模板中,
{% for entry in entries %}
{% set_disqus_identifier entry.id %}
{% set_disqus_url entry.get_absolute_url %}
{% set_disqus_developer 1 %}
{% blog stuff goes here %}
{%endfor%}
在列出我在文章模板中
{% set_disqus_identifier entry.id %}
{% set_disqus_url entry.get_absolute_url %}
{% set_disqus_developer 1 %}
<section id="comments">
<a href="{{ entry.get_absolute_url }}#disqus_thread" data-disqus-identifier="{{ entry.id }}">View Comments</a>
<h1>{% disqus_num_replies %}</h1>
<article class="comment">
{% disqus_dev %}
{% disqus_show_comments entry.get_absolute_url %}
我遇到了我之前提到的问题,即如果我发布一条评论,disqus 会将其应用于所有博客文章。我想我对标识符做了一些错误的事情,但是当我查看源代码时,JavaScript 为每篇博客文章获取了正确的 id,
我真的需要它才能工作,所以将永远感激任何帮助或建议,使这个工作
Hi my client is desperate to integrate django disqus into the blog we have built for them. I stumbled upon https://github.com/arthurk/django-disqus django disqus app and couldnt believe my luck, i had this up and running in no time, everything appears to be working ok, im posting comments etc however it dosent seem to be identifying properly as a comment posted with object.id for one blog post appears for all posts through out the blog.
in the index template that lists all the blog posts out i have
{% for entry in entries %}
{% set_disqus_identifier entry.id %}
{% set_disqus_url entry.get_absolute_url %}
{% set_disqus_developer 1 %}
{% blog stuff goes here %}
{%endfor%}
in the article template i have
{% set_disqus_identifier entry.id %}
{% set_disqus_url entry.get_absolute_url %}
{% set_disqus_developer 1 %}
<section id="comments">
<a href="{{ entry.get_absolute_url }}#disqus_thread" data-disqus-identifier="{{ entry.id }}">View Comments</a>
<h1>{% disqus_num_replies %}</h1>
<article class="comment">
{% disqus_dev %}
{% disqus_show_comments entry.get_absolute_url %}
the problem as i mentioned before is that if i post one comment disqus is applying that to all the blog posts. I guess im doing something wrong with the identifiers, but when i view source the javascript is getting the right id for each blog post
I really need this to work so will be eternally grateful for any help or advice that has got this working
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在索引模板中,您不需要执行所有这些 set_* 操作。因此,只需加载 dev 标签即可启用本地开发:
在您的文章模板中,只需执行此操作即可显示评论。 disqus javascript 将使用当前 URL 作为标识符,因此无需手动设置:
不要忘记将设置设置为文档中所述的正确值: http://django-disqus.readthedocs.org/en/latest/installation.html#configuring- your-django-installation 并且将 Site 对象的 url 更改为您的实际域。
in your index template, you don't need to do all this set_* stuff. So just load the dev tag to enable local development:
In your article template just do this to display the comments. The disqus javascript will use the current URL as the identifier, so there's no need to set it manually:
Don't forget to set the settings to the correct values as described in the documentation: http://django-disqus.readthedocs.org/en/latest/installation.html#configuring-your-django-installation And also change the url of your Site object to your actual domain.
我认为您不应该在索引模板中设置标识符和其他值。由于 for 循环,它会覆盖以前的值。相反,您应该在模板中设置与特定帖子相关的值。这样,您就可以为该特定帖子设置 disqus 参数。
注意:django-disqus 现在有更新的版本,支持 django 1.7。
I think you should not set the identifier and other values in index template. Because of the for loop its overriding the previous values. Rather, you should set the values in template related to particular post. That way, you would be setting disqus parameters for that particular post.
Note: django-disqus has newer version now, with django 1.7 support.