1👍
I suppose this should do
Table.objects.order_by('-user_id').distinct('user_id')
See distinct() in this -> https://docs.djangoproject.com/en/1.9/ref/models/querysets/
But this will only work if the latest log entry for that user is the last entry by that user in the table, i.e., the log entries of a particular user as sorted in ascending way in the table.
0👍
Table.objects.order_by('user_id', '-datetime').distinct('user_id')
Add indexes to user_id
and datetime
(Meta.index_together = ['user_id', 'datetime']
).
- Changing data-tooltip with AJAX isn't working
- Installing Scipy.stats on pythonanywhere
- Django external api calls
- Missing Variable Error in Django Form After Form Submission
Source:stackexchange.com