You can use jQuery in the Django admin area :
class MenuAdmin(admin.ModelAdmin):
class Media:
js = ('/static/admin/js/hide_attribute.js',)
ModelAdminand InlineModelAdminhave a property mediathat returns a list of media objects that store JavaScript file paths for the form and / or form.
Contents of hide_attribute.js:
hide_page=false;
django.jQuery(document).ready(function(){
if (django.jQuery('#id_has_submenu').is(':checked')) {
django.jQuery(".page").hide();
hide_page=true;
} else {
django.jQuery(".page").show();
hide_page=false;
}
django.jQuery("#id_has_submenu").click(function(){
hide_page=!hide_page;
if (hide_page) {
django.jQuery(".page").hide();
} else {
django.jQuery(".page").show();
}
})
})
Namespaces:
, Djangos jQuery ( 3.3.1) django.jQuery.