Django left join with and condition

2019-06-03 Thread chirag soni
I have 3 models Product,Photo,ProductLikeDislike. I am left joining all the three. For that I wrote this query: x=Product.objects.values_list('name','photo','productlikedislike') Through this I am getting correct left join I printed and checked like this: *Note*: olx is the name of my Django ap

Re: left join with and condition

2018-12-05 Thread Mark Phillips
Take a look at 'Q objects' in the django documentation - https://docs.djangoproject.com/en/2.1/ref/models/querysets/#django.db.models.Q Perhaps F objects will help. https://docs.djangoproject.com/en/2.1/ref/models/expressions/#django.db.models.F Mark On Wed, Dec 5, 2018 at 9:12 AM Arnaldo Díaz M

left join with and condition

2018-12-05 Thread Arnaldo Díaz Molina
Hello and thanks in advanced, I am using Django 1.11 ORM. I need to make this SQL query: SELECT model1.field1, sum(model2.field1), sum(model2.field2) FROM model1 LEFT JOIN model2 on model2.model1_id=model1.id and model2.date='2018-12-02' group by model1.field1 I have used annotations for this ki