1👍
✅
It’s not pretty code but. Using django’s ‘extra’ queryset method and where as an argument you can achieve getting back the desired result set. i.e.
Table.objects.extra(where=['id IN (SELECT id FROM table_name'
' GROUP BY user_id HAVING MIN(time))'])
Source:stackexchange.com