0
<QuerySet 
    [{'product': 6, 'quantity': 1}, 
    {'product': 6, 'quantity': 10}, 
    {'product': 7, 'quantity': 2}, 
    {'product': 9, 'quantity': 3}]
>

how to get unique elements only in the array and add the quantity if same product is found. In the above eg: there are two "product: 6", so the new QuerySet should be

<QuerySet 
    [{'product': 6, 'quantity': 11}, 
    {'product': 7, 'quantity': 2}, 
    {'product': 9, 'quantity': 3}]
>
beck
  • 2,967
  • 3
  • 16
  • 27

0 Answers0