I'm using Django's TabularInline
admin view to edit category objects related to a main topic object, as shown here:
Is there a way to not show the rendered names of the objects ("General Questions", "Media Handling and Margins", etc. in this example), without creating a custom admin template? In other words, I just want to show a clean grid of input fields.
I found the relevant rendering code here, at this fragment:
... <td class="original"> {% if inline_admin_form.original or inline_admin_form.show_url %}<p> {% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %} {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a>{% endif %} </p>{% endif %} ...
Is there a short, clever way to omit the {{ inline_admin_form.original }}
or have it return Null?
@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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With