Z
Z
zkweb2016-12-29 10:41:15
Django
zkweb, 2016-12-29 10:41:15

Django, how to get rid of duplicates in comments?

76466c1eb1bd4933911e37c177a31390.JPG
in the ListView I show the last comments to the entry, as a result, there are duplicates.
{% for publisher in object_list %}
{% get_comment_list for mk.mk publisher.pk as comment_list %}
Where is the right place to specify select_related?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iegor, 2016-12-29
@iegor

Not select, but prefetch. Where you get object_list.

A
Alexander Lebedev, 2016-12-29
@zymanch

Apparently your django_comments are being retrieved in the get_comment_list method (probably a template tag).
Is this a self-written method or did you install some package? If self-written, then in it, and if the method is from a package, then I would take its code and transfer it to my template tag, where I would already prefetch all the necessary related objects

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question