Initial
Sales.objects.filter(sales_person=self)
Select Related (O2O)
Sales.objects.select_related().filter(sales_person=self)
Prefetch Related (M2M / M2O)
Sales.objects.select_related().prefetch_related('booking_set', 'advancepayment_set', 'others_set').filter(sales_person=self)
More info:
https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related
https://docs.djangoproject.com/en/dev/ref/models/querysets/#prefetch-related
No comments :
Post a Comment