3๐
โ
I have found the solution for this, new querysets in views.py will be as follows:
id_list = Talk_comment.objects.filter(user=user_info_obj).values('user','talk').annotate(Max('id')).values('id__max')
qs = Talk_comment.objects.filter(pk__in=id_list)
๐คD Dhaliwal
0๐
Your views.py code is problematic here. It will return only the values of the user columns with annotations, rather than returning an actual queryset which allows you to walk through the relation between Talk_comment and Talk.
I believe altering that line to the following will get you closer to your goal.
qs = Talk_comment.objects.annotate(max_id=Max('id')).order_by('-max_id')
๐คWalter
- [Django]-It's possible to use django mysql model array field
- [Django]-Django nginx admin media
- [Django]-How to rebuild virtualenvs after deleting associated python interpreter
- [Django]-Django REST Framework Filter Queryset Based On URL
Source:stackexchange.com