Hook to be able to customize changelist_view
|Reported by:||Igor Sobreira||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, the changelist_view uses self.queryset to display the list of objects instances. So, to customize what changelist will use, you need to customise self.queryset. The bad point is that change_view also uses self.queryset, and maybe you don't wan't do affect it.
For example: I have a list of Page objects, that could have subpages. The subpages are Pages too, but are not listed in changelist. But you should be able to edit subpages (since they are Page objects). I've attached an image of my admin with this use case.
If I customize self.queryset to hide subpages (in changelist view), I can't access subpages form (change view) anymore.
I've attached a patch fix this. Just creating a self.queryset_changelist hook. And changing ChangeList to use it. Now I can customize what changelist will show me, without affecting what I can edit.