搭建Django博客(4)多说评论框

  1. 注册多说账号,得到多说short_name

  2. myblog/templates文件夹新建duoshuo.html并加入代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <!-- 多说评论框 start -->
    <div class="ds-thread" data-thread-key="{{ post.id }}" data-title="{{ post.title }}"></div>
    <!-- 多说评论框 end -->
    <!-- 多说公共JS代码 start -->
    <script type="text/javascript">
    <!-- short_name 填自己的多说名字 -->
    var duoshuoQuery = {short_name:"wish007"};
    (function() {
    var ds = document.createElement('script');
    ds.type = 'text/javascript';ds.async = true;
    ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
    ds.charset = 'UTF-8';
    (document.getElementsByTagName('head')[0]
    || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
    </script>
    <!-- 多说公共JS代码 end -->
  3. 在需要增加多说评论框的</div>标签前面添加以下代码

    1
    {% include "duoshuo.html" %}