• Members 49 posts
    June 24, 2018, 3:30 p.m.

    I have a custom index page which has nothing to do with the forum. The only relation to it, is that I want to show the two or three latest threads from misago in the sidebar.
    I want to show:

    • Thread title
    • Text/body (I'll cut it off using css)
    • Date/time created
    • Thumbnail of user avatar (like in misago's index).

    Would it be possible to get the data and share it with my index/frontpage app?

    I'm thinking something in the line of getting context data like this in the index/frontpage apps view.

    from relevant.misago.models import title, text, avatar, date/time

    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)
        context['latest_title2'] = relevant.objects.values_list('relevantobject', flat=True).latest
        context['latest_title1'] = relevant.objects.values_list('relevantobject', flat=True).order_by('-pk')[1]
    
        context['latest_text2'] = relevant.objects.values_list('relevantobject', flat=True).latest
        context['latest_text1'] = relevant.objects.values_list('relevantobject', flat=True).order_by('-pk')[1]
    
        context['latest_date/time2'] = relevant.objects.values_list('relevantobject', flat=True).latest
        context['latest_date/time1'] = relevant.objects.values_list('relevantobject', flat=True).order_by('-pk')[1]
    
        context['latest_avatar2'] = relevant.objects.values_list('relevantobject', flat=True).latest
        context['latest_avatar1'] = relevant.objects.values_list('relevantobject', flat=True).order_by('-pk')[1]