arthurk / django-disqus

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

disqus_identifier not being set #78

Open int-ua opened 7 years ago

int-ua commented 7 years ago

Update/Resolution: In case {% with %} is used {% disqus_show_comments %} must be placed before the closing {% endwith %}. Looks like it's worth a mention in the docs. Close it if you think otherwise.

Older comment: This line does nothing: https://github.com/arthurk/django-disqus/blob/0db52c240906c6663189c0a7aca9979a0db004d1/disqus/templates/disqus/show_comments.html#L6

Django 1.8.18 django-disqus 0.5 Python 3.4

I've set it up long ago and didn't check it. It was working without this config. At least we thought it was until we found out that comments are published on wrong pages and wrong links were formed by Disqus.

int-ua commented 7 years ago

With this code it outputs only disqus_url:

{% with item|model_name as disqus_prefix %}
{% with item.id|stringformat:"s" as item_id %}
    {% set_disqus_identifier disqus_prefix "_" item_id %}
{% endwith %}
{% endwith %}

{% set_disqus_url request.build_absolute_uri %}
int-ua commented 7 years ago

It is being set in set_disqus_identifier() but it's somehow no longer present in get_config()

int-ua commented 7 years ago

Found it. In case {% with %} is used {% disqus_show_comments %} must be placed before the closing {% endwith %}.

SalahAdDin commented 7 years ago

@int-ua Did you solve your problem?

Solition/acclaration must be putted in documentation.

int-ua commented 7 years ago

Yes, it should, but I'm not sure how to phrase it better, I'd like someone else doing it.

SalahAdDin commented 7 years ago

Let me see the documentation about it.

@int-ua Can you put here the final code?

And, can you sahre with me your user case? You are trying a list of post with number comments, aren you? Interesting.

I used the next code:

<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>

Is the normal use, for this reason there aren't other notes about other alternatives about how use it.

int-ua commented 7 years ago

My final code:

    {% with item|model_name as disqus_prefix %}
    {% with item.id|stringformat:"s" as item_id %}
        {% set_disqus_identifier disqus_prefix "_" item_id %}
        {% set_disqus_url request.build_absolute_uri %}
        {% disqus_show_comments %}
    {% endwith %}
    {% endwith %}

And I still get all comments on one page but that's another issue.