Python Django Admin Form: show inline without rendering a form

I have a Django admin page which allows me to edit a model in my domain. The ModelAdmin looks like this:

@admin.register(models.VehicleTemplate)
class VehicleTemplateAdmin(ModelAdminBase):
    list_reverse_relation_inline = False
    search_fields = ["name", "description"]
    list_display = ["name", "description", "parent", "status"]
    inlines = [VehicleInline]
    readonly_fields = [
        "config",
        "status",
        "properties"
    ]
    fields = [
        "step",
        "name",
        ....
    ]

...

class VehicleInline(InlineModelAdmin):
    model = models.Vehicle

    def has_add_permission(self, request, obj=None):
        return False

    def has_change_permission(self, request, obj=None):
        return False

    def has_delete_permission(self, request, obj=None):
        return False

    ....

The VehicleInline can contain thousands of child models of VehicleTemplate, which ends up rendering thousands of inline forms which all get submitted together when the admin change form is submitted/saved. However, nothing in the VehicleInline is editable. So, instead, I would like to simply display the contents of these child models without rendering any form or input elements. The root problem I have is that the number of form elements is more than the absolute_max configured in Django so it fails the form submission even though none of the inline data is editable.

I have tried many, many ways of preventing the form widgets from rendering by providing empty widgets and editing the InlineModelAdmin to not include the input HTML but I eventually just run into a management form manipulation error.

How can I display these child models inline on the change page but not include any of the details in the form submission?

Вернуться на верх