Answer the question
In order to leave comments, you need to log in
Django subquery?
I want to make a request with a subquery using Django ORM, like
SELECT log_out.id, log_out.site_id, log_out.date
FROM (
SELECT site_id, max(date) AS max_date
FROM main_uploadedprofilelog
GROUP BY site_id
) AS log_in
INNER JOIN main_uploadedprofilelog AS log_out ON log_out.site_id = log_in.site_id AND log_out.date = log_in.max_date;
items = UploadedProfileLog.objects.values('site_id').annotate(Max('date'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question