The script below shows how to add the collapse button to the django admin filters.
In the static directory, which is configured in the django settings STATICFILES_DIRS, create the file changelist_filter_collapse.js inside /admin/js. For example, if your STATICFILES_DIRS is mapped to the statics directory, the file would look like this /statics/admin.js/changelist_filter_collapse.js.
// changelist_filter_collapse.js
// The original code for the snippet is here: https://gist.github.com/duducp/0c5b32f7936b924b39c10e5983de1199#file-changelist-filter-collapse-md
// Wait for the DOM to be fully loaded before running the script
document.addEventListener('DOMContentLoaded', function() {