django-jazzmin
django-jazzmin copied to clipboard
Support for inline/fieldsets collapse
There currently isn't support for collapsing inline models. i.e. classes = ['collapse'] results in the objects disappearing entirely.
Collapse has no effect on fieldsets, i.e.
fieldsets = (
('General', {
'fields': ('foo', 'bar',),
'classes': ('collapse',),
}),
)
Which changeform_format are you using within your JAZZMIN_SETTINGS ? the default one horizontal_tabs ? or one of the others ?
on a seperate note, I dont see fieldset classes coming through on all changeforms, so I've got a PR up to address that See https://github.com/farridav/django-jazzmin/pull/375
But id need to understand your use case a little bit more to know if it helps..
Mostly using horizontal_tabs
I'll be using collapse in several fieldsets, but primarily right now, looking to collapse some large inline models.
class VersionInlineAdmin(admin.StackedInline):
model = Version
# fieldsets = (
# ('General', {
# 'fields': ('foo', 'bar',),
# 'classes': ('collapse',),
# }),
# )
Tested this manually by adding:
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button> to the "card-header" div, like so:
<div class="card-header">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
...</div>
It appears as if the button needs to be added to the card header.
Presumably this needs to be added to the stacked inline template, around line 13, in the <div class="card-header"> element.
I have same observation, Setting 'classes': ('collapse',), in admin fieldsets does nothing. I'm using changeform_format set to single.
similar observations about inlines model, when you set settings classes = ['collapse'], you could observe browser console logs
collapse.js:17 Uncaught TypeError: Cannot read properties of null (reading 'appendChild')
at collapse.js:17:20
(anonymous) @ collapse.js:17
load (async)
(anonymous) @ collapse.js:4