Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove title from TabularInline in admin

When I create a TabularInline in my Django's admin panel, it displays a title per record. How can I change this title? How can I delete this title?

I include a screenshot below. The title I am referring to is here ExportLookupTableElement object. The lines without that title are the extra fields to add new ones. I want the entire table to look like this.

Screenshot

like image 640
physicalattraction Avatar asked Feb 05 '23 10:02

physicalattraction


1 Answers

You can remove this title by overriding Django's admin css:

  1. Create css/custom_admin.css in your static directory with following code:
.inline-group .tabular tr.has_original td {
    padding-top: 8px;
}

.original {
    display: none;
}
  1. Edit your admin.py file to include this extra css for ModelAdmin that you want to remove title:
class TestDetailInline(admin.TabularInline):
    model = TestDetail

class TestAdmin(admin.ModelAdmin):
    class Media:
        css = {
            'all': ('css/custom_admin.css', )     # Include extra css
        }
    inlines = [TestDetailInline]

example django admin after override

Or you can override css for all admin pages by following this answer.

like image 131
nattster Avatar answered Feb 08 '23 16:02

nattster