Django has no built-in way to do this that I know of, but I can come up with a couple of ways that you could do something once, instead of manually modifying many fields.
One approach is to use javascript to overwrite page layout. Perhaps javascript may have a list of field names and whenever it finds one of them, it hides the field and its label and adds a button to the page to switch these invisible fields.
Another approach would only include python. Usually you simply specify the fieldsets attribute in admin as a tuple. But you can specify it as an imported function that takes a regular tuple as an argument. In your settings file, you can specify a list of field names that you want to hide. Then you need to write a function that returns the modified tuple, moving any fields that match one of your field names to a new set of fields along with the collapse class.
For example, in your admin class, you can do something like this (you need to write and import hide_fields).
fieldsets = hide_fields( (None, {'fields':('title', 'content')} ) )
This can be interpreted as the following: it is assumed that the contents are in the settings file as something you want to hide:
fieldsets = ( (None, {'fields':('title',)} ), ('Extra', { 'fields': ('content',), 'classes':('collapse',), } ), )
source share