```
# Here is my models

```

This is my CustmerBuySell model DB designed.

```
class CustomerBuySell(models.Model):
    customer = models.ForeignKey(CustomerAdd, on_delete=models.CASCADE)
    customer_buy_sell_debit = models.DecimalField(max_digits=10, decimal_places=2, default=0.00)
    customer_buy_sell_credit = models.DecimalField(max_digits=10, decimal_places=2, default=0.00)
    description = models.CharField(max_length=250, blank=True)
    date = models.DateField()
    sms = models.BooleanField(default=False)
    picture = models.ImageField(upload_to='customer_buy_sell_pics', default='images.png')

    created_at = models.DateTimeField(auto_now_add=True, blank=True, null=True)
    updated_at = models.DateTimeField(auto_now=True, blank=True, null=True)

    def __str__(self):
        return self.customer.customer_name

    class Meta:
        verbose_name = "Customer BuySell"
        verbose_name_plural = "Customer BuySell"

# Here, is my View.

```

This is the class-based APIView, which I have used. And try to use the aggregate query in this view.

```
class DailyCustomerBuySellAPIView(APIView):

    def get(self, request):
        customer_buy_sell = CustomerBuySell.objects.extra(select={'day': 'date( date )'}).values('day').order_by(
            'date__date').annotate(available=Count('date__date'))
        serializer = CustomerBuySellSerializer(customer_buy_sell, many=True)
        return Response({"customer_buy_sell": serializer.data})

# And, finally here are my Serializers

```

I have no idea what's the problem! Please help me.

```
class CustomerBuySellSerializer(serializers.ModelSerializer):
    # customer = CustomerAddSerializer()

    class Meta:
        model = CustomerBuySell
        fields = '__all__'

    def to_representation(self, instance):
        representation = super(CustomerBuySellSerializer, self).to_representation(instance)

        if instance.customer is not None:
            customer_name = instance.customer.customer_name
            previous_due = instance.customer.previous_due
            representation['custo`enter code here`mer_name'] = customer_name
            representation['previous_due'] = previous_due
            return representation

```