Last active
August 23, 2024 05:32
-
-
Save channprj/81b26a3a169ec29a3d1fd994b9121169 to your computer and use it in GitHub Desktop.
Toggle Django Admin Filter Panel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$(document).ready(function($) { | |
$("tr input.action-select").actions(); | |
$('<div id="show-filters" style="float: right;"><a href="#">← 필터 보기</a></p>').prependTo('div.actions'); | |
$('#show-filters').hide(); | |
$('#changelist-filter h2').html('<a style="color: white;" id="hide-filters" href="#">필터 →</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); |
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
Converted with pure JS with Copilot