[Answered ]-Django only() and values() are not working with prefetch_related()

1👍

Remove 'seller_salary' from the fields. Annotations are added automatically, so:

sellers = Seller.objects.annotate_seller_salary().prefetch_related(
    Prefetch(
        'seller_products',
        Product.objects.filter(points__gt=0).order_by('id')
    )
).only('points')

Leave a comment