Tuesday, January 1, 2013

Get objects sorted by time of last comment

Hi All, 

A very happy new year to you all !

I am working on a website I am making as my hobby project. It is to do with motorcycle touring. 

I have done some initial work on it, and incrementally making changes as and when I can. 

I am trying to figure out the following issue : 
1. I have a forum object where people can start threads. 
2. the forum object uses the django comments module along with mptt. So far so good. 
3. Now, I want to show the "latest commented on" posts. But I am not able to figure it out. 


On the box on the right, I want to show the posts based on the last comment time. However, all I can do right now is show the last post based on creation time (this is a field for the post object). I am not able to figure out how to sort based on comment time. 

Solutions :
1. Ideally there should be a way to sort object by comment time using the inbuilt comments module in django. Is this possible ? 
2. Alternatively, I will need to update the post model to have another field for 'last_comment_time' and when someone posts a comment, I will need to update this field. I would rather not do this as I will need to make sure all the objects using comments will need to have this exact field. 

What would you suggest ? 

Vibhu

--
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment