Changes between Version 1 and Version 2 of Ticket #26780, comment 9


Ignore:
Timestamp:
Apr 20, 2018, 11:53:08 AM (7 years ago)
Author:
Tim Graham

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26780, comment 9

    v1 v2  
    33from django.db.models import OuterRef, Subquery
    44
    5 User.objects.all().prefetch_related('comments',queryset=Comment.objects.filter(id__in=Subquery(Comment.objects.filter(user_id=OuterRef('user_id')).values_list('id', flat=True)[:5])))
     5`User.objects.all().prefetch_related('comments',queryset=Comment.objects.filter(id__in=Subquery(Comment.objects.filter(user_id=OuterRef('user_id')).values_list('id', flat=True)[:5])))`
Back to Top