I have a book model and a rating model,
class Book(models.Model): title = models.CharField(max_length=255) slug = AutoSlugField(unique=True, populate_from='title') description = models.TextField()
Request,
books = {'books': Book.objects.filter(pk__in=Rating.objects.all().order_by('-score' ).values_list('book__id', flat=True))[:10] }
template,
{% for i in books %} {{ i.title }}, {{ i.rating_set.all.first.score }} <br/> {% endfor %}
displays the model in a template, but the django debug toolbar appears as Duplicated n times, where n is the number of objects in the list. when I use query caching, its normal.

What is happening, how can I fix it?
thanks.
python django django-templates django-queryset
Rivadiz
source share