arthurk / django-disqus

Integrates DISQUS into Django
http://django-disqus.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
327 stars 101 forks source link

Got disqus working without this extension. cant get api key anymore without pro upgrade #77

Open kinganu opened 7 years ago

kinganu commented 7 years ago

Hey, I was looking for a commenting system solution for a Django blog and it was quite troublesome to engineer one from ground zero within Django. So I found out that I could use disqus. I saw your extension and figured it was the best solution. Turns out it is no longer needed, since you can't get an API key without a pro upgrade on disqus, and it is easier to use their universal code JS snippet to embed the commenting system easily.

For anyone curious here is what I did. Create an account at disqus, select 'I want to use it in my site', add your sites shortname and domain (in my case Im devving locally on ubuntu VM and used my dev domain I created 'djang0.me' for my test django blog). Go to installation instructions, select 'universal code' at bottom and copy the code. I decided to use an include disqus block in my django blogs Post template, which is very nice:

# blog/includes/disqus.html

{% block disqus %}

<div class="container">
    <div class="row">

<a class="btn btn-default arches" role="button" data-toggle="collapse" href="#dcomments" aria-expanded="true" style="width: 120px; display: block; margin: 0 auto; margin-top: 20vh;"> <h4 class="text-success"> Comments &raquo; </h4> </a>

        <div class="col-md-6 col-md-offset-3">

            <div class="panel collapse stucco" id="dcomments" style="margin-top: 10vh;">

<div id="disqus_thread"></div>

            </div>

        </div>
    </div>
</div>

<script>
/**
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = djang0.me;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = sldtech; // 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 = 'https://sldtech.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>

<script id="dsq-count-scr" src="//sldtech.disqus.com/count.js" async></script>

{% endblock %}

# blog/post.html

                        {% extends "blog/blogbase.html" %}  

                                        {% block body %}        

<div class="container">
        <div class="col-md-12 text-center">
            <h6 class="pull-right"> on {{ post.date }} </h6> <br>
            <h3> {{ post.title }} </h3> <br>
        <img src="{% if post.image %} {{ post.image.url }} {% endif %}" class="img-responsive center-block" align="left" alt=""> 
                <p> {{ post.body|safe|linebreaks }} </p>
        </div>
</div>                                                      

{% include 'blog/includes/disqus.html' %}
{% block disqus %}{% endblock %}

                                {% endblock %} 

Only thing Im a little confused about is, they recommend uncommenting the variables: //this.page.url = djang0.me; // Replace PAGE_URL with your page's canonical URL variable //this.page.identifier = ; // Replace PAGE_IDENTIFIER with your page's unique identifier

Would you know what should I use for this.page.identifier in a django blog, if anything?

SalahAdDin commented 7 years ago

The commonly use is put and slug, of if you want, generate a ramdom identifier and put it:

<div id="fb-root">
        <!-- TODO: Review this with documentation -->
        {% set_disqus_identifier self.slug %}
        {% set_disqus_title self.title %}
        {% set_disqus_url self.full_url %}
        {% disqus_dev %}
        {% disqus_show_comments %}
</div>

These is my example.