I have a SQL query which I am trying to make it as a Django ORM, tried many ways but didn't get the exact solution for it.
select c.* from product p
left join voucher v on v.id = p.voucher_id
left join customer c on c.id = v.customer_id
where p.id=3;
Django Model are,
class Customer(models.Model):
customer_name = models.CharField(max_length=200, default="", db_index=True)
mobile = models.IntegerField(default='')
class Voucher(models.Model):
voucher_name = models.CharField(max_length=100, default='')
customer = models.ForeignKey(Customer,db_index=True)
class Product(models.Model):
product_name = models.CharField(max_length=100, default='')
rate = models.FloatField(max_length=50)
voucher = models.ForeignKey(Voucher, db_index=True)