﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33547	Admin TabularInline with readonly field fail to render on validation error	David Glenck	Mariusz Felisiak	"Error Message ""'dict' object has no attribute 'is_hidden'""
In this line https://github.com/django/django/blob/e0442a628eb480eac6a7888aed5a86f83499e299/django/contrib/admin/templatetags/admin_modify.py#L141
Here in the template https://github.com/django/django/blob/e0442a628eb480eac6a7888aed5a86f83499e299/django/contrib/admin/templates/admin/edit_inline/tabular.html#L28

In my case the reasong is that the field in the inline is readonly which makes it a dict without the ""is_hidden"" attribute.

Code to reproduce.
Model:
{{{
class MyModel(models.Model):
    other_model = models.ForeignKey('OtherModel', on_delete=models.CASCADE)

    def clean(self):
        raise ValidationError()
}}}

Inline:

{{{
class MyModelInline(admin.TabularInline):
    model = MyModel
    readonly_fields = ['my_readonly_field']

    @admin.display(description='MyReadonlyField')
    def my_readonly_field(self, instance):
        return 'value'
}}}

Then using this tabular inline in OtherModelAdmin.
Trying to add a new MyModel in OtherModel via admin will raise the ValidationError and consequently cause this issue.

Changing this line https://github.com/django/django/blob/e0442a628eb480eac6a7888aed5a86f83499e299/django/contrib/admin/templatetags/admin_modify.py#L141 to:
{{{
if not getattr(field.field, 'is_hidden', False):
}}}
Seems to fix the issue.
"	Bug	closed	contrib.admin	4.0	Release blocker	fixed	tabularinline readonly	Antoine Humbert	Ready for checkin	1	0	0	0	0	0
