Django 的 Disqus 通用代码
Disqus universal code for Django
我尝试在我的站点中安装 disqus,但页面上没有显示任何内容。站点 url - djaway.net
这是我的代码:
views.py
def detail(request, slug):
url = (reverse('content:detail', args=[slug]))
content_info = Post.objects.get(slug = slug)
return render(request, 'detail.html', {'content_info':content_info, 'url':url})
template.html
<script>
var disqus_config = function () {
this.page.url = 'djaway.net{{ url }}'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '{{ url }}'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'djaway.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>
标记 {{ url }}
return 正确的链接,例如 /content/slug/
您缺少 URL 中的 https://
用于加载 disqus javascript:
s.src = 'https://djaway.disqus.com/embed.js';
最好包含 http://
或 https://
(取决于您的站点是否使用 https):
this.page.url = 'https://djaway.net{{ url }}';
我尝试在我的站点中安装 disqus,但页面上没有显示任何内容。站点 url - djaway.net 这是我的代码:
views.py
def detail(request, slug):
url = (reverse('content:detail', args=[slug]))
content_info = Post.objects.get(slug = slug)
return render(request, 'detail.html', {'content_info':content_info, 'url':url})
template.html
<script>
var disqus_config = function () {
this.page.url = 'djaway.net{{ url }}'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '{{ url }}'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'djaway.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>
标记 {{ url }}
return 正确的链接,例如 /content/slug/
您缺少 URL 中的 https://
用于加载 disqus javascript:
s.src = 'https://djaway.disqus.com/embed.js';
最好包含 http://
或 https://
(取决于您的站点是否使用 https):
this.page.url = 'https://djaway.net{{ url }}';