[Answer]-Django admin changelist foreignKey from froreignKey sortable

1👍

class ActivityAdmin(admin.ModelAdmin):
    list_display = [
        'title',
        'task',
        'project',
    ]

    def project(self, obj):
        return obj.task.project.name

    project.admin_order_field = 'task__project__name'

admin.site.register(Activity, ActivityAdmin)

Leave a comment