﻿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
30520	ModelForm with field without label crashes when used in InlineModelAdmin.	George Tantiras	Jones	"As per [https://stackoverflow.com/questions/56156039/extra-field-of-modelform-without-label-does-not-render-in-inlinemodeladmin this] and [https://stackoverflow.com/questions/54511865/django-extra-fields-in-custommodelform-is-giving-unable-to-lookuup-error-i that] S.O. issues, although a ModelForm with an extra field which has no label works at the model's change view, it raises an error when the same ModelForm is used for an inline:

models.py:
{{{#!python
class Parent(models.Model):
    pass


class Child(models.Model):
    parent = models.ForeignKey(Parent, on_delete=models.PROTECT)
}}}

forms.py:
{{{#!python
class ChildForm(forms.ModelForm):
    extra_field = forms.CharField()

    class Meta:
        model = Child
        fields = '__all__'
}}}
admin.py:
{{{#!python
@admin.register(models.Child)
class ChildAdmin(admin.ModelAdmin):
    '''The ModelForm renders as expected'''
    form = forms.ChildForm


class ChildInline(admin.TabularInline):
    '''Here the ModelForm without a label in the extra field, will raise error'''
    model = models.Child
    form = forms.ChildForm


@admin.register(models.Parent)
class ParentAdmin(admin.ModelAdmin):
    inlines = (ChildInline,)
}}}
{{{#!python
     File ""/home/venv/lined/lib/python3.7/site-packages/django/contrib/admin/utils.py"", line 364, in label_for_field
     raise AttributeError(message)
     AttributeError: Unable to lookup 'extra_field' on Child or ChildInline
}}}
Full error message:
https://pastebin.com/89MUGchf"	Bug	closed	contrib.admin	dev	Normal	fixed			Accepted	1	0	0	0	1	0
