title: Convert raw sql query to django orm
body: <p>I written this query in PostgreSQL and I'm confused of conversion of this query to django orm</p>
  <pre><code>SELECT count(*),
         concat(date_part('month', issue_date), '/', date_part('year', issue_date) ) as date 
  FROM affiliates_issuelog 
  WHERE tenant_id = '{tenant_id}' 
  GROUP BY date_part('month', issue_date),
           date_part('year', issue_date) 
  ORDER BY  date_part('year', issue_date) desc,
            date_part('month', issue_date) desc
  </code></pre>
  <p>I have this model that records the insertion of new affiliates by date and by institution (tenant), only I need to receive from the query the total amount of records inserted per month in the year, and I was using the listview to make my pages until then but I don't know how to filter this data using orm.</p>
  <pre><code>class IssueLog():
      tenant = models.ForeignKey(&quot;tenants.Federation&quot;, on_delete=models.CASCADE)
      issue_date = models.DateField(
          default=date.today, verbose_name=_(&quot;date of issue&quot;)
      )
  
      class Meta:
          verbose_name = _(&quot;Entrada de emissão&quot;)
          verbose_name_plural = _(&quot;Entradas de emissão&quot;)
  
      def __str__(self):
          return f&quot;{self.institution}, {self.tenant}&quot;
  </code></pre>
  <p>My pages that return a list of data I did as the example below, is it possible to pass the data as I want through get_queryset()?, I already managed to solve my problem using the raw query, but the project is being done only with orm so I wanted to keep that pattern for the sake of the team. Ex:</p>
  <pre><code>class AffiliateExpiredListView(HasRoleMixin, AffiliateFilterMxin, ListView):
      allowed_roles = &quot;federation&quot;
      model = Affiliate
      ordering = &quot;-created_at&quot;
      template_name_suffix = &quot;issued_list_expired&quot;
      paginate_by = 20
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context[&quot;renew_form&quot;] = AffiliateRenewForm()
          tenant_t = self.request.user.tenant
          context[&quot;cancel_presets&quot;] = tenant_t.cancelationreason_set.all()
          return context
  
      def get_queryset(self):
          return super().get_queryset().filter(is_expired=True).order_by('full_name')
  </code></pre>