The point is that there is a way, in fact multiple ways that this could be implemented without changing the models. A change to the method I suggested in my last mail would be to avoid looping over the query set at all or even the Entry() class and using values and the the Count() annotation in a single query and instead of showing the repr of the object deleted we could say something like “Deleted 1item” or “Deleted 10 items” which on click could show us the group of items being talked about.
Akshat: I’m not sure how you plan on grouping the query set appropriately using javascript. I don’t think that is implementable. And even if it is, I don’t see how it would be more efficient.
Carles Pina I Estany: While I understand what you’re trying to do I don’t know why we are trying to avoid COUNT is there a best practice associated with this that I don’t know about?
However I do see a concern in adding a loop to the queryset right there in python. A slightly better solution would be simply saying
Entries = LogEntry.objects.values(‘action_time’,’action_flag’,’user’).annotate(no_of_items = Count(‘id’)) and switching up things like
{{ entry.object_repr }} in index.html to accommodate the dictionary that will be returned so that recent actions doesn’t deal directly with action objects at all.
Another proposal which would solve the problem of potentially encapsulating too much would be to add a view for a logs.html that shows very single query with pagination for the query set. This way the users who really want to see all the details of all of the logs, have a way to do it (without having to make query to logEntry on their end) and the recent actions will have a lot cleaner look.
I’m sure there are little details that can always be improved in every solution. I would really appreciate your inputs on the same
Adam: Let me know if this seems like a remotely satisfactory solutions or if there are other problems I should consider.
If this seems like a helpful proposal I would like to take this entire segment up for my GSoC Proposal in 2021.
Regards
Muskan Vaswan