How to Configure a column not to visible by default in django admin

I want to hide one column and make the column visdible but if user want the user view the column, i tried this way but did not worked forr me.

admin.py

class ProductAdmin(TimestampedModelAdminMixin, ConfigurableColumnsMixin, admin.ModelAdmin):


list_display = [
           "id",
          "comment",
           "active",
          ]

I tried with this way but did not worked.

 def get_form(self, request, obj=None, **kwargs):
    form = super(ProductAdmin, self).get_form(request, obj, **kwargs)
    del form.base_fields["comment"]
    return form

You can specify the fields that you want to show in the fieldset in the admin class. You can refer to docs here

Generic syntax for fieldset (from the docs)

class FlatPageAdmin(admin.ModelAdmin):
    fieldsets = (
    (None, {
        'fields': ('url', 'title', 'content', 'sites')
    }),
    ('Advanced options', {
        'classes': ('collapse',),
        'fields': ('registration_required', 'template_name'),
    }),
)
Back to Top