Django Group by month and payment mode, get a report in template only for the datas present

class Transactions(models.Model):
        ('income', 'Income'),
        ('expense', 'Expense'),

        ('cash', 'Cash'),
        ('enbd', 'ENBD'),
        ('nol', 'NOL'),
        ('sib', 'SIB'),

    trans_id = models.AutoField(primary_key=True)
    trans_date = models.DateField(verbose_name="Date")
    trans_type = models.CharField(max_length=10, choices=TRANSACTION_TYPE_CHOICES, verbose_name="Type")
    trans_details = models.ForeignKey(Details, on_delete=models.CASCADE, verbose_name="Details", related_name="trnsactions")
    trans_category = models.ForeignKey(MasterCategory, on_delete=models.CASCADE, verbose_name="Category", related_name="transactions")
    trans_mode = models.CharField(max_length=10, choices=PAYMENT_MODE_CHOICES, verbose_name="Payment Mode")
    trans_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="Amount")

    objects = models.Manager()

    class Meta:
        verbose_name_plural = "Transactions"

    def __str__(self):
        return f"{self.trans_id} - {self.trans_type} - {self.trans_details} - {self.trans_category} - {self.trans_amount}"

above is my model, and below is my view

def by_mode(request):
    all_modes = dict(Transactions.PAYMENT_MODE_CHOICES).keys()

    totals = Transactions.objects.annotate(
    ).values('month', 'mode').annotate(

    data = {}
    for total in totals:
        month = total['month'].strftime('%B')
        mode = total['mode']
        if mode not in data:
            data[mode] = {}
        data[mode][month] = total['total']

    return render(request, 'by_mode.html', {'data': data, 'modes': all_modes})

below is my template

{% extends 'base.html' %}

{% block content %}
  <h1>Transactions by Payment Mode</h1>
  <table class="table">
        {% for mode in modes %}
          <th>{{ mode|title }}</th>
        {% endfor %}
      {% for month, mode_totals in data.items %}
          <td>{{ month }}</td>
          {% for mode in modes %}
            <td>{{ mode_totals }}</td>
          {% endfor %}
      {% endfor %}
{% endblock %}

I want to display a report on every month as a table
horizontal should have months and vertical should have trans_mode.

Any reply on this?
I have been waiting for more than 10 days.