Hi Vibhu,

You have more than one option, I think:
1)Modify model's Meta class and add an order_by = 
('-comment__creation_date',)
2)Make a view that does just that last_threads_commented = 
Thread.comments.order_by('-comment__creation_date')
3)Make a custom template tag that does all of the heavy lifting behind the 
scenes.

disclaimer: I am not really sure if you can employed any of the methods 
listed here on a Generic Model tho, use at your own risk...

thank you,
Victor Rocha
RochApps <http://www.rochapps.com>

On Wednesday, January 2, 2013 1:50:17 AM UTC-5, Vibhu Rishi wrote:
>
> 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. 
>
> For reference : http://bikenomads.herokuapp.com/
>
> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/t_Drdvmj9AEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to