title: Is it possible re-write `raw-sql` to `django-orm`?
body: <p>I need to re-write <code>raw-sql</code> to <code>django-orm</code>. But unfortunately I can't do it. Does someone has ideas ?:</p>
  
  <pre><code>HttcOrder.objects.raw('''SELECT httc_order.id, httc_order.price, httc_order.quantity,
                                          SUM(markedskraft_trade.qty) as positions_quantity
                                          FROM httc_order left outer join markedskraft_trade on httc_order.id = markedskraft_trade.httc_order_id
                                          WHERE httc_order.order_status in ('new', 'pending', 'confirmed')
                                          and httc_order.mk_contract_id = %s
                                          group by httc_order.id
                                          having positions_quantity is NULL or quantity - positions_quantity &gt; 0
                                          order by httc_order.price desc''', [contract.id])
  </code></pre>
  
  <p>Example of models:</p>
  
  <p>httc:</p>
  
  <pre><code>class Order(models.Model):
      quantity = models.IntegerField(verbose_name=_('Qty'))
      order_status = models.CharField(max_length=10, choices=ORDER_STATUSES, default=NEW)
      price = models.IntegerField(verbose_name=_('Prc'))
      mk_contract = models.ForeignKey(
          Contract, related_name='httc_orders', verbose_name=_('Markedskraft contract')
      )
      ....
  </code></pre>
  
  <p>markedskraft:</p>
  
  <pre><code>   class Trade(models.Model):
         order_id = models.IntegerField(blank=True, null=True, db_index=True)
         httc_order_id = models.ForeignKey(HttcOrder, blank=True, null=True, db_index=True)
         qty = models.IntegerField()
         .......
  </code></pre>