'Django admin action delete_selected to be the last option in the drop-down list

I would like to display the delete_selected action in the drop-down list in the admin screen as the last option just for one model.



Solution 1:[1]

I managed to make it work like this. Would be there a nicer way?

class MyModelAdmin(admin.ModelAdmin):

    actions = ['soft_delete_selected', 'soft_undelete_selected']

    def get_actions(self, request):
        actions = super().get_actions(request)
    
        action = actions['delete_selected']
        del actions['delete_selected']
        actions['delete_selected'] = action

        return actions

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nik_m