Re: NotImplemented error combining distinct with annotate

2019-07-22 Thread John Gateley
Thank you Simon, that worked. -- John On Sun, Jul 21, 2019 at 8:55 PM Simon Charette wrote: > Assuming you have a model definition `Salesperson` you could use > > Salesperson.object.annotate( > sales_amount=Sum('sales__sales_amount'), > ) > > But given you mentioned 'salesperson' is a text f

Re: NotImplemented error combining distinct with annotate

2019-07-21 Thread Simon Charette
Assuming you have a model definition `Salesperson` you could use Salesperson.object.annotate( sales_amount=Sum('sales__sales_amount'), ) But given you mentioned 'salesperson' is a text field you can do persons = Sales.objects.values('salesperson').annotate( sum_sales_amount=Sum('sales_am

NotImplemented error combining distinct with annotate

2019-07-21 Thread John Gateley
Hello, Python version: Python 3.7.2 Django version: 2.2.3 I want to combine distinct and annotate(Sum(...)), and get the following error: NotImplementedError: annotate() + distinct(fields) is not implemented. To describe: I have a bunch of sales entries like: 'John', 100 'Sam', 50 'John', 200 (t