1👍
✅
Well, firstly you need to define a URL for the sales list view that includes the ID of the customer whose details you want to see:
url(r'^sales/(?P<id>\d+)/$', SaleList.as_view(), name='sale_list'),
Then you need to provide a link in the customer list to that view:
{% for customer in object_list %}
<tr>
<td><a href="{% url 'sale_list' id=customer.id %}">{{ customer.full_name }}</a></td>
and then you need to filter by that ID in the queryset for the sales list view:
def get_queryset(self):
s = Sale.objects.filter(customer=self.kwargs['id'])
return s
Source:stackexchange.com