Skip to content

Instantly share code, notes, and snippets.

@channprj
Last active August 23, 2024 05:32
Show Gist options
  • Save channprj/81b26a3a169ec29a3d1fd994b9121169 to your computer and use it in GitHub Desktop.
Save channprj/81b26a3a169ec29a3d1fd994b9121169 to your computer and use it in GitHub Desktop.
Toggle Django Admin Filter Panel
(function($) {
$(document).ready(function($) {
$("tr input.action-select").actions();
$('<div id="show-filters" style="float: right;"><a href="#">&larr; 필터 보기</a></p>').prependTo('div.actions');
$('#show-filters').hide();
$('#changelist-filter h2').html('<a style="color: white;" id="hide-filters" href="#">필터 &rarr;</a>');
$('#show-filters').click(function() {
$('#changelist-filter').show('fast');
$('#changelist').addClass('filtered');
$('#show-filters').hide();
});
$('#hide-filters').click( function() {
$('#changelist-filter').hide('fast');
$('#show-filters').show();
$('#changelist').removeClass('filtered');
});
});
})(django.jQuery);
@channprj
Copy link
Author

Add like below in admin.py

class SampleModelAdmin(admin.ModelAdmin):
    # ...
    class Media:
        js = ("js/admin_overrides.js",)
        css = {"all": ("css/admin_overrides.css",)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment