How to omit object name from Django's TabularInline admin view?

后端 未结 6 1860
南方客
南方客 2021-02-01 14:33

I\'m using Django\'s TabularInline admin view to edit category objects related to a main topic object, as shown here:

6条回答
  •  孤街浪徒
    2021-02-01 15:27

    @sjaak-schilperoort Nice one! CSS is indeed the 'trick' to use. Example of the class Foo which has Bar as inline.

    static/css/hide_admin_original.css:

    td.original p {
      visibility: hidden
    }
    
    .inline-group .tabular tr.has_original td {
        padding-top: 5px;
    }
    

    admin.py:

    class FooAdmin(admin.ModelAdmin):
      inlines = [ BarInline, ]
      class Media:
        css = { "all" : ("css/hide_admin_original.css",) }
    
    admin.site.register(Foo, FooAdmin)
    

提交回复
热议问题