How to order_by() last content `saved` in Admin Dashboard rather than by `date` or `id`.

The next thing to look at would be the template.

But there are a couple little things to point out.

You have:

Your second definition is going to overwrite the first. So for the rest of the view, script_type will contain a reference to the ContentType for ScriptSuggestion. You do not have a reference to the ContentType for Research, which means that:

Is not going to work

Eureka! You got it working!

You have a good eye. I am not sure how I missed that. I have 5 context dictionary key declarations in this ListView. This time I declared each with a unique script_type variable. Everything runs beautifully. The lists of content titles are now ordered by LogEntry updates.

The original elabroate annotate algorithm that Ken came up with works well. Thanks again for the help. :slightly_smiling_face:

For what it is worth, here is my current working ListView:

class ContentListView(LoginRequiredMixin,ListView):
    model = Content
    # template_name = 'home.html'   
        
    def get_context_data(self, **kwargs):
    
        # Call the base implementation first to get a context
        context = super(ContentListView, self).get_context_data(**kwargs)
        
        script_type1 = ContentType.objects.get_for_model(ScriptSuggestion)
        context['scriptsuggestions'] = ScriptSuggestion.objects.annotate(
            last_change=Subquery(
                LogEntry.objects.filter(
                    content_type=script_type1,
                    action_flag=CHANGE,
                    object_id=Cast(
                        OuterRef('id'), 
                        CharField()
                        )
                    ).order_by('-action_time').values('action_time')[:1]
                )
            ).order_by('-last_change')
        
        script_type2 = ContentType.objects.get_for_model(Research)
        context['research'] = Research.objects.annotate(
            last_change=Subquery(
                LogEntry.objects.filter(
                    content_type=script_type2,
                    action_flag=CHANGE,
                    object_id=Cast(
                        OuterRef('id'), 
                        CharField()
                        )
                    ).order_by('-action_time').values('action_time')[:1]
                )
            ).order_by('-last_change')
        
        script_type3 = ContentType.objects.get_for_model(Induction)
        context['inductions'] = Induction.objects.annotate(
            last_change=Subquery(
                LogEntry.objects.filter(
                    content_type=script_type3,
                    action_flag=CHANGE,
                    object_id=Cast(
                        OuterRef('id'), 
                        CharField()
                        )
                    ).order_by('-action_time').values('action_time')[:1]
                )
            ).order_by('-last_change')
        
        script_type4 = ContentType.objects.get_for_model(StockScript)
        context['stockscripts'] = StockScript.objects.annotate(
            last_change=Subquery(
                LogEntry.objects.filter(
                    content_type=script_type4,
                    action_flag=CHANGE,
                    object_id=Cast(
                        OuterRef('id'), 
                        CharField()
                        )
                    ).order_by('-action_time').values('action_time')[:1]
                )
            ).order_by('-last_change')
        
        context['preambles'] = Preamble.objects.all()
        
        return context