Django的通用代码

时间:2018-01-24 13:40:21

标签: django disqus

我尝试在我的网站上安装disqus,但页面上没有显示任何内容。网站网址 - 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 }}返回右侧链接,例如/content/slug/

1 个答案:

答案 0 :(得分:0)

您缺少用于加载disqus javascript的网址中的https://

s.src = 'https://djaway.disqus.com/embed.js';

包含http://https://(取决于您的网站是否使用https)可能是个好主意:

this.page.url = 'https://djaway.net{{ url }}';