Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I count only replies on the every Comment? #101

Open
tanveerahmad1517 opened this issue Sep 7, 2018 · 1 comment
Open

How can I count only replies on the every Comment? #101

tanveerahmad1517 opened this issue Sep 7, 2018 · 1 comment

Comments

@tanveerahmad1517
Copy link

Please I want to show the replies number on every comment that are available replies

@gameot
Copy link

gameot commented Jan 18, 2019

extend model like this:

from threadedcomments.models import ThreadedComment as BaseModel
class ThreadedCommentExt(BaseModel):
    class Meta:
        verbose_name = _("Comment")
        verbose_name_plural = _("Comments")
        proxy = True
        managed = False

    def get_replies_count(self):
        count = 0
        comments = ThreadedCommentExt.objects.filter(parent=self)
        for item in comments:
            count += item.get_replies_count() + 1
        return count        

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants