0
# models.py
class Book(TimeStampedModel):
name = models.CharField(_('nome'), max_length=50)
authors = models.ManyToManyField('Author', verbose_name='autores')
price = models.DecimalField(_(u'preço'), max_digits=5, decimal_places=2)
# views.py
class BookList(ListView):
template_name = 'core/book_list.html'
model = Book
def get_queryset(self):
''' use prefetch_related for m2m performance '''
b = Book.objects.prefetch_related('authors').all()
return b
You guys really think you need to prefetch_related
to improve the performance of queryset? Or not need? Django’s CBV already does this automatically?